简体   繁体   English

多个查询在phpmyadmin中插入但在php脚本中不起作用

[英]mutiple insert Query Works in phpmyadmin but does not work in php script

I have a project on godaddy shared hosting. 我有一个关于Godaddy共享托管的项目。 I am able to run the following query in phpmyadmin successfully: (this is the exact output of the php script) 我能够在phpmyadmin中成功运行以下查询:(这是php脚本的确切输出)

INSERT INTO payments_facebook(`adset`,`amount`,`date`,`oid` ) VALUES ('6023516764849','3.27','2015-07-25','58'); 
INSERT INTO payments_facebook(`adset`,`amount`,`date`,`oid` ) VALUES ('6023315002249','200','2015-07-25','53'); 
INSERT INTO payments_facebook(`adset`,`amount`,`date`,`oid` ) VALUES ('6023221698649','3.43','2015-07-25','52')

I am using the old mysql_query function to insert the data. 我正在使用旧的mysql_query函数插入数据。 When I run this query through PHP I get a following error message: 通过PHP运行此查询时,出现以下错误消息:

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 'INSERT INTO payments_facebook(`adset`,`amount`,`date`,`oid` ) VALUES ('602331500' at line 1

but when I run the same query in phpmyadmin it works perfectly. 但是,当我在phpmyadmin中运行相同的查询时,它可以完美运行。

Here is the structure of the mysql table: 这是mysql表的结构:

  • id int(100): id int(100):
  • date varchar(30) latin1_swedish_ci 日期varchar(30)latin1_swedish_ci
  • oid int(50) oid int(50)
  • amount double 数量加倍
  • adset varchar(200) latin1_swedish_ci adset varchar(200)latin1_swedish_ci

Hopefully someone can help me figure this out, I am not sure if this is a godaddy server limitation or if I have an error in my DB or syntax. 希望有人可以帮助我解决这个问题,我不确定这是否是godaddy服务器的限制,还是我的数据库或语法有错误。

Thank you in advance. 先感谢您。

Try this : 尝试这个 :

$sql = "INSERT INTO payments_facebook(`adset`,`amount`,`date`,`oid` ) VALUES 
('6023516764849','3.27','2015-07-25','58'),
('6023315002249','200','2015-07-25','53'),
('6023221698649','3.43','2015-07-25','52')";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM