MYSQL错误:MySQL server version for the right syntax to use near '1' at line 1PHP插入数据$linkDB01 = mysql_connect("local","amount","code");\x05mysql_select_db("blueShine01",$linkDB01);\x05mysql_query("set names utf8;");\x05$insert01 = mysql_q

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 11:39:22
MYSQL错误:MySQLserverversionfortherightsyntaxtousenear''1''atline1PHP插入数据$linkDB01=mysql_connect("local"

MYSQL错误:MySQL server version for the right syntax to use near '1' at line 1PHP插入数据$linkDB01 = mysql_connect("local","amount","code");\x05mysql_select_db("blueShine01",$linkDB01);\x05mysql_query("set names utf8;");\x05$insert01 = mysql_q
MYSQL错误:MySQL server version for the right syntax to use near '1' at line 1
PHP插入数据
$linkDB01 = mysql_connect("local","amount","code");
\x05mysql_select_db("blueShine01",$linkDB01);
\x05mysql_query("set names utf8;");
\x05$insert01 = mysql_query( "INSERT INTO barCodeTB01 (barCode,uploadTime,agencyName,queryTime,checkTime)VALUES('112233445566','20140908','哈哈',NOW(),'1') ");\x05
//插入数据
\x05if mysql_query($insert01,$linkDB01)) { die('Error:' .mysql_error()); } else { echo "1 record added"; };\x05
//询问是否插入数据成功
mysql_close($linkDB01);
数据可以成功插入,在数据库内能查到.但是同时的会页面也会返回
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 '1' at line 1.
噢···知道了
$insert01 = mysql_query( "INSERT INTO barCodeTB01 (barCode,uploadTime,agencyName,queryTime,checkTime)VALUES('112233445566','20140908','哈哈',NOW(),'1') ");\x05
//赋值插入数据这一句是不能加mysql_query()的
改成:
$insert01 = "INSERT INTO barCodeTB01 (barCode,uploadTime,agencyName,queryTime,checkTime)VALUES('112233445566','20140908','哈哈',NOW(),'1')";
//这样就没问题了萌萌哒~

MYSQL错误:MySQL server version for the right syntax to use near '1' at line 1PHP插入数据$linkDB01 = mysql_connect("local","amount","code");\x05mysql_select_db("blueShine01",$linkDB01);\x05mysql_query("set names utf8;");\x05$insert01 = mysql_q
最好是能够有代码行的错误信息,就是说明你哪行代码对应的SQL语句出的问题,这样更好分析.
根据代码,目测可能有以下问题:
1
pstmt=conn.prepareStatement("select username from user where username=?");
pstmt.setString(1,shopname);
这段中如果shopname是null的话执行结果可能有问题,所以最好先判断以下shopname是否非null.
2
String sql ="insert into shop(shopname,price,number,brand,date) values ('"+shopname+"','"+price+"','"+number+"','"+brand+",'"+date+"');";
这个段中是否都是字符型?,还有就是'"+brand+",少了一个引号
这样可以么?