php 無效sql結果資源 mysql
江蘇農二代農林生態發展有限公司
include "conn/conn.php";
?>
?>
客戶服務 | 常見問題 | 農莊專家 | 招商加盟 | 設為首頁
- 首 頁
- 走進農二代
- 新聞中心
- 特種養殖
- 綠色產品
- 園林工程
- 服務涵蓋範圍
- 人力資源
- 客戶留言
- 聯絡我們
|
|
|
if($_GET['identification'] != null){ $sql = mysql_query("select * from frontpagenews where identification = ".$_GET['identification']."order by createDate desc limit 0,7"); 這裡報錯 while($result = mysql_fetch_array($sql)){ ?>
|
|
|
} }else{ $sql = mysql_query("select * from frontpagenews where identification = 1 order by createDate desc limit 0,7"); while($result = mysql_fetch_array($sql)){ ?>
|
|
|
} } ?>
|
錯誤資訊
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Apache\htdocs\growers\news.php on line 147
回複討論(解決方案)
$sql = mysql_query("select * from frontpagenews where identification = ".$_GET['identification']." order by createDate desc limit 0,7");
mysql_query("select * from frontpagenews where identification = ".$_GET['identification']. "order by createDate desc limit 0,7");
除非 $_GET['identification'] 最後的字元是空格,不然 $_GET['identification'] 的值不就和 order 連在一起了?
如果 $_GET['identification'] = 1
你的 sql指令不就了
"select * from frontpagenews where identification = 1order by createDate desc limit 0,7"
嗎?
粗心要人命啊。多謝了。少個空格