Sandeep Bansal
Sandeep Bansal

Reputation: 6404

SQL Backup not working with PHP Script

I am using the script found at this blog post.

What I am trying to do is output the SQL Code onto the screen and then using file_get_contents from my local web server to get the SQL Query and mysql_query it to my local database.

The problem is when I do this it gives me an 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...

If I copy and paste the SQL Code from the screen it's executed perfectly fine.

I know this is quite a weird request but if someone could help me find the problem it'll be great.

Upvotes: 0

Views: 118

Answers (1)

Eli Y
Eli Y

Reputation: 907

well i used this

    $file = file_get_contents("db-backup-1316832550-6f1ed002ab5595859014ebf0951522d9.sql");
foreach(explode(';', $file) as $value => $key)
{
if($key == ''){continue;}

echo $key;
mysql_query($key) or die(mysql_error());
}

of course the file is example one

there's seems to be a problem with the delimiter = ";"

Upvotes: 1

Related Questions