PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
i am beginner in php and i am trying to insert information into existing table in mysql database and creating new table at the same time but get an error :
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 'CREATE TABLE 4532 ( billid varchar(20), PRIMARY KEY(billid), medname varchar' at line 3
All I did was added a ; after the insert statement to separate it from the create statement.
i tried that before but still getting an error :
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 'CREATE TABLE 2222 ( billid varchar(20), P' at line 4
i tried using letters but still getting the same error :
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 'CREATE TABLE hamdan ( billid varchar(20), ' at line 4
I'm guessing that you are using the PHP mysql API, if that is the case you should know that mysql API doesn't support multi-queries.
you have 2 options:
a) separate your INSERT and CREATE (and by the way... why you need to have the CREATE in your code?) in 2 queries and execute them separately or
b) use the mysqli API that support multi-queries but you also should know that it is more difficult to program the proper error controls in your code using multi-queries.