-------------------------------
$temp[2] = str_replace("'", "''", $temp[2]); // Add this code.
$query="SELECT * FROM validate where (serial_number='$temp[2]' and
v_setting='$temp[4]' and i_setting='$temp[5]');";
$result=mysql_query($query) or die("Error: ". mysql_error(). " with
query ". $query);
$countone = mysql_num_rows($result);
-------------------------------
※ 引述《sionkozx (sionkozx)》之銘言:
: 我用maysql+PHP
: 以下是錯誤訊息:
: SELECT * FROM validate where (serial_number=''9909121913011605' and
: v_setting='220' and i_setting='8');
: Error: 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
: '9909121913011605' and v_setting='220' and i_setting='8')' at line 1 with
: query SELECT * FROM validate where (serial_number=''9909121913011605' and
: v_setting='220' and i_setting='8');
: 我知道問題出在那個引號~
: 我的temp[2]本身就是'9909121913011605
: 用過很多種方式還是沒辦法順利搜尋~
: serial_number我要儲存為前面有帶一個引號的字串共17碼~
: 但是都會出現
: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
: resource in XXXX錯誤。
: 以下是程式碼:
: $query="SELECT * FROM validate where (serial_number='$temp[2]' and
: v_setting='$temp[4]' and i_setting='$temp[5]');";
: $result=mysql_query($query) or die("Error: ". mysql_error(). " with
: query ". $query);
: $countone = mysql_num_rows($result);//有幾筆
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.242.250.151