MYSQL错误:MySQL server version for the right syntax to use nea
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/11/08 23:11:36
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')";
//这样就没问题了萌萌哒~
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')";
//这样就没问题了萌萌哒~
最好是能够有代码行的错误信息,就是说明你哪行代码对应的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+",少了一个引号
这样可以么?
再问: 呃···这是啥子东西···代码行没有错误消息,就只有这么一句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。
你的回答我看不懂啊···T。T···
根据代码,目测可能有以下问题:
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+",少了一个引号
这样可以么?
再问: 呃···这是啥子东西···代码行没有错误消息,就只有这么一句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。
你的回答我看不懂啊···T。T···
check the manual that corresponds to your MySQL server versi
MySQL Error Message:Can not connect to MySQL server
我每次开机用navicat打开MySQL都出现错误:2003-can't connect to mysql server
Can not connect to MySQL server是什么意思
mysql
英语翻译Warning:mysql_connect():Lost connection to MySQL server
Can not connect to MySQL server这是什么意思?
$halt && $this->halt('Can not connect to MySQL server');这句是什
MySQL Error:You have an error in your SQL syntax; check the
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'loc
MySQL-mysql里是什么意思
英文翻译过来说【MySQL服务器错误:】