-1
我想從MYSQL打印文章的列表,但我不斷收到錯誤。PHP的 - 回聲html代碼和變量從MySQL查詢
while($row = mysql_fetch_assoc($query)){
echo "<article class='post'>
<h2><a style='color:#43484d' href='' " .$row['url']. ";</a></h2>
<ul class='meta'>
<li><span>level :</span> <span style='color:red'>" .$row['Level']. " </span></li>
<li><span>Negative votes by visitors :</span> " .$row['negativeVotes']. "</li>
<li><span>Positive votes by visitors :</span>" .$row['positiveVotes']. "</li>
<li><span style='color:#000; cursor:pointer' class='fa fa-thumbs-o-up'></span></li>
<li><span style='color:#000; cursor:pointer' class='fa fa-thumbs-o-down'></span></li>
</ul>
</article>"
}
?>
我得到這個
Parse error: syntax error, unexpected '}', expecting ',' or ';'.
我做了什麼錯? 非常感謝!
添加一個分號';''後「' – Qirel
如果你正在編寫新的代碼,** _ please_不使用'mysql_ *'功能**他們是破爛不堪,被棄用在PHP 5.5中(它已經很老了,它甚至不再接收安全更新),並在PHP 7中完全刪除。使用['PDO'](https://secure.php.net/manual/en/book.pdo.php )或['mysqli_ *'](https://secure.php.net/manual/en/book.mysqli.php)替代_prepared statements_和_parameter binding_參見http://stackoverflow.com/q/12859942/ 354577查看詳細信息 – Chris
請分享$ query變量,可能是因爲sql沒有正確寫入而導致解析錯誤 –