可能重複:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL resultmysql_fetch_assoc()問題
我收到此錯誤信息:
警告:mysql_fetch_assoc():提供的參數是不是一個第215行的/.../.../..../index.php中有效的MySQL結果資源
的index.php代碼:
if (isset($_GET['post_id']) && $_GET['post_id'] != '')
{
$p_id = (int) $_GET['post_id'];
$sql= mysql_query("SELECT * FROM news_post WHERE post_id = '$p_id' AND block = 0 LIMIT
$offset, $rowsperpage") or mysql_error();
}
else
{
$sql= mysql_query("SELECT * FROM news_post WHERE block = 0 ORDER BY post_id DESC
LIMIT $offset, $rowsperpage ") or mysql_error();
}
while ($rel = mysql_fetch_assoc($sql)) (Note: this is Line 215)
{
$id = intval($rel['post_id']);
$sub = ucfirst($rel['subject']);
$imgname = htmlentities($rel['img_name']);
$img = htmlentities($rel ['image']);
$msg = $rel['message'];
$date = htmlentities($rel['date']);
$poster = htmlentities($rel['poster']);
$cat_id = intval($rel['cat_id']);
$cat_name = htmlentities($rel['cat_name']);
在我的本地主機,這是確定的,它不顯示任何錯誤消息,但最多時該到我的服務器,然後它顯示錯誤.. 什麼是錯的我的代碼?誰能告訴我正確的方向...
非常感謝。
變化'或mysql_error();''來或死亡(mysql_error());',看看你會得到什麼。 – Josh 2012-03-28 16:36:31