作者Ifreet (Ifreet)
看板Database
标题Re: [SQL ] 请教一下这个错误讯息
时间Thu Jun 6 10:18:38 2013
-------------------------------
$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