When I execute:
mysql_query("SELECT * FROM people WHERE fname = '$fname'; INSERT INTO people (first_name) VALUES ('$fname')") or die(mysql_error());
I receive this 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 'INSERT INTO people (first_name) VALUES ('Draski')' at line 1
Where is the syntax error?
You can't do run two queries in one statement with the mysql_*
API. You will have to run them in two separate queries.
You can do it with mysqli_*
, however. And since the mysql_*
API is deprecated you should be using an alternative API like mysqli_*
anyway.
使用此函数mysqli_multi_query进行多个查询。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.