在我的Ajax 聊天脚本中,我收到了以下警告:
Warning: mysql_fetch_array() expects parameter 1 to be resource,
boolean given in /home/mychat/public_html/c/listChats.php on line 7
第 7 行:
while($row = mysql_fetch_array($sql)){
listChats.php:
<?php
$chats = "";
include_once("scripts/connect_db.php");
$sql = mysql_query("SELECT * FROM (
SELECT * FROM chatBox order by id DESC LIMIT 20
) TMP ORDER BY tmp.id ASC");
while($row = mysql_fetch_array($sql)){
$chat = $row['chatBody'];
$username = $row['username'];
$chats = '<p><span id="un">' . $username . ':</span> ' . $chat . '</p>';
echo "$chats";
}
?>