error php and mysql

<?php do { ?>
<?php
   if(isset($row['website']) && !empty($row['website']))
{
    echo '<a href="'.$row['website'].'" target="_self\">'.$row['name'].''.$row['publisher'].'</a>';
} else {
    echo .$row['name'].$row['publisher'];
}
?>

<?php } while ($row = mysql_fetch_assoc($rowDetails)); ?>

I am getting syntax error which i cannot find can somebody help me?

Answers


$row['name'] instead of $row['name].

Also, you can write this code like that:

if (isset($row['website']) && !empty($row['website']))
    echo '<a href="'.$row['website'].'" target="_self\">'.$row['name].$row['publisher'].'</a>';
else
    echo $row['name'].$row['publisher'];

Or better:

echo (isset($row['website']) && !empty($row['website'])) ?
    '<a href="'.$row['website'].'" target="_self\">'.$row['name].$row['publisher'].'</a>' :
        $row['name'].$row['publisher'];

You are missing a closing single quote here -->$row['name]

It should be $row['name']

Also, read up on the empty function, it will not work on referenced array members; it only works on variables.

UPDATE

You also have an issue in your else block --> echo .$row['name']...

You need to remove the '.' before $row.


Don't use so many statements. Php is a scripting language and compiles on the fly (assuming no APC or caching), by having so many open and closing php statements you are giving Php more work to do for nothing.


Need Your Help

Handling NA and NAN in R

r na

I am attempting to run a simple simulation of 100,000 instances for the code below. When attempting to get the sd and mean of of dlogP I am receiving sd(dlogP):NA and mean(dlogP): NaN. I believe i ...

Issues while connecting to the intersystems cache from Java

intersystems-cache intersystems

I am trying to write an example to connect to the Intersystems Cache from a Java class. I am using the eXtreme Data Objects framework from Intersystems Cache`. Here is the source code -

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.