作者appleboy46 (我是道明柏毅)
看板PHP
標題Re: [請益] Mysql Syntax Error
時間Sat May 13 23:39:03 2006
※ 引述《rpuppy (funny)》之銘言:
: Could not run query: You have an error in your SQL syntax; check the manual
: that corresponds to your MySQL server version for the right syntax to use
: near 'check='1'' at line 1
: 程式碼如下:
: $sql="select count(*) from $friend where check='1'";
$sql = sprintf("select count(*) from `%s` where `check` = '1'", $friend);
這樣寫 比較不會有錯誤 將來也會比較好維護
: $result=mysql_query($sql,$db);
: if(!$result) {
: echo 'Could not run query: ' . mysql_error();
: exit;
: }
: 請問是版本更新所造成的問題嗎? 懇請各位大大回答
: 謝謝各位!
--
********************************************************
* 瘋狂小惡魔分享討論區 *
*
http://www.forum.Wu-Boy.com/index.php *
* 無名相簿-appleboy *
*
http://www.wretch.cc/album/appleboy *
********************************************************
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.203.237.84
1F:推 rpuppy:可以正常執行了!! 感謝^^ 05/14 01:23