FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Urgent! MySQL error!





cr3ativ3
This is an urgent problem I am trying to use php to implement an SQL backup and well below is the backup but it keeps throughing me this error:

Quote:
Could not write database: 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 '; -- -- Database: `oysolut_show` -- -- ---------------------------------------' at line 10


Please don't just tell me the problem I realize is has something to do with the syntax but hopefully it is just a quick fix one of you can fix for me thanks!

Hey I might just through some Frih$ for it aswell anyway's here is the php script:

http://www.oysolutions.com/mysql.txt

THANK YOU![/quote]
MrBlueSky
You try to do multiple queries with one mysql_query(). That's not supported, so when mysql encounters a semicolon it gives an error: semicolons are used to seperate different queries.

You need to split the string into single queries and call mysql_query() for each. You might have a look at explode(), and do something like this (Pseudocode):

Code:


$queries = explode(";", $query);
for (i=0; i<length of $queries) {
   send query $queries[$i] to mysql
}

rvec
it has something to do with this if I remember right:
ENGINE=MyISAM DEFAULT CHARSET=latin1
i'll search the forum for a couple of min

edit: seems to be another version of mysql Embarassed
can't you just import it with phpmyadmin?
cr3ativ3
MrBlueSky wrote:
You try to do multiple queries with one mysql_query(). That's not supported, so when mysql encounters a semicolon it gives an error: semicolons are used to seperate different queries.

You need to split the string into single queries and call mysql_query() for each. You might have a look at explode(), and do something like this (Pseudocode):

Code:


$queries = explode(";", $query);
for (i=0; i<length of $queries) {
   send query $queries[$i] to mysql
}



K I tried adapting that with the query command thing and strlen on the length of part but I keep getting a different every error every thing I do would you be able to apapt that to my script fully. I need to have this fixed before the end of the night =\.
MrBlueSky
Hmm, this is going to be a problem because you also have semicolons in your data. It's better if you just use phpMyAdmin to import the SQL. In phpMyAdmin select the database, click the 'SQL' tab and paste the sql-dump into the textfield (make sure to remove the existing tables from the dbase first).
cr3ativ3
Hey, thanks everyone I will be sending some Frih$ to certain people but ya using MrBlueSky's advice I was able to make 57 seperate query's lol, while watching out for the semicolons in the data but ya so it works perfect now!

Thanks Everyone this topic can be closed as it is resolved.
Related topics
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.