Mysql and PHP - Reading multiple insert queries from a file and executing at runtime
Posted
by SpikETidE
on Stack Overflow
See other posts from Stack Overflow
or by SpikETidE
Published on 2010-04-27T04:40:20Z
Indexed on
2010/04/27
4:43 UTC
Read the original article
Hit count: 263
Hi everyone...
I am trying out a back-up and restore system. Basically, what i try to do is, when creating the back up i make a file which looks like
DELETE FROM bank_account; INSERT INTO bank_account VALUES('1', 'IB6872', 'Indian Bank', 'Indian Bank', '2', '1', '0', '0000-00-00 00:00:00', '1', '2010-04-13 17:09:05');INSERT INTO bank_account VALUES('2', 'IB7391', 'Indian Bank', 'Indian Bank', '3', '1', '0', '0000-00-00 00:00:00', '1', '2010-04-13 17:09:32');
and so on and so forth.
When i restore the db i just read the query from the file, save it to a string and then execute it over the DB using mysql_query();
The problem is, when i run the query through mysql_query(), the execution stops after the delete query with the error
'Error in syntax near '; INSERT INTO bank_account VALUES('1', 'IB6872', 'Indian Bank', 'Indian Bank', '2',' at line 1.
But when i run the queries directly over the Db, using phpmyadmin it executes without any errors.
As far as i can see, i can't notice any syntax error in the query. Can anyone point out where there might be a glitch...?
Thanks and regards....
© Stack Overflow or respective owner