nimrod
nimrod

Reputation: 5732

Appending variable in PHP causes Syntax Error

What is wrong with this php code?

$sql = mysql_query("select * from news where isActive = 1 and partnerid_fk = '$partnerid'");
$news = "";
while($row = mysql_fetch_assoc($sql)) {
    news .= "<li class='news-item'><a href='#'>" . $row['news'] . "</a></li>";
}

Error on the news append line:

Syntax error. 

Upvotes: 0

Views: 51

Answers (1)

John Conde
John Conde

Reputation: 219884

You forgot your dollar sign:

news .= 

should be

$news .= 

Upvotes: 4

Related Questions