Php MYSQL查询语法设置错误

Php MYSQL查询语法设置错误,php,mysql,syntax-error,Php,Mysql,Syntax Error,我可以在PHPMyAdmin中运行以下查询,但由于某种原因,当我在PHP中的mysql方法中运行它时,会出现语法错误: INSERT INTO product (model, stock_status_id, image, price, date_available, status, date_added, date_modified) VALUES('SP44152', 5, 'data/products/SP44152-1.jpg', '18.04', '2012-06-18', 1, '

我可以在PHPMyAdmin中运行以下查询,但由于某种原因,当我在PHP中的mysql方法中运行它时,会出现语法错误:

INSERT INTO product (model, stock_status_id, image, price, date_available, status, date_added, date_modified) 
VALUES('SP44152', 5, 'data/products/SP44152-1.jpg', '18.04', '2012-06-18', 1, '2012-06-19 00:31:35', '2012-06-19 00:57:01'); 
SET @lastid = LAST_INSERT_ID(); 
INSERT INTO product_description (product_id, language_id, name, Description) 
VALUES(@lastid, 1, 'Product item 1', 'Product Description'); 
INSERT INTO product_reward (product_id, customer_group_id, points) 
VALUES(@lastid, 1, 0);  
INSERT INTO product_to_category (product_id, category_id) 
VALUES(@lastid, 67); 
INSERT INTO product_to_store (product_id, store_id) VALUES(@lastid, 0);
我得到的错误代码是:

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 'SET @lastid = LAST_INSERT_ID(); INSERT INTO product_description (product_i' at line 3
我已经试着把它移走了;从每一行的末尾,我尝试删除“status”字段,因为我知道这也是可以在MYSQL中使用的。互联网上似乎没有太多东西可以帮助我们找出这起事件的原因

欢迎任何反馈。

不喜欢多个分号分隔的语句:

mysql_query()发送一个唯一的查询(不支持多个查询) 已支持)的服务器上的当前活动数据库 与指定的链接标识符关联

将查询分解为多个查询并逐个执行:

mysql_query("INSERT INTO product ...", $conn);
$lastid = mysql_insert_id($conn); // you can use mysql_insert_id() PHP function
mysql_query("INSERT INTO product_description ...", $conn);
mysql_query("INSERT INTO product_reward ...", $conn);
mysql_query("INSERT INTO product_to_category ...", $conn);
mysql_query("INSERT INTO product_to_store ...", $conn);

PS:我建议您查看
mysql.*
函数。

为什么不使用php函数mysql\u insert\u id()?您在第一次查询中遇到问题,请正确检查字段名称,在
status\u id
value和status
value
上加引号,谢谢Feida,我确实使用了您的建议。