Hi there,
I'm trying to insert the contents of a mysql dump file into a table, but there's a problem.
At the moment cutting the header of the mysql dump file to be left with just the inserts (I couldn't find a switch in the mysqldump commands to turn off the headers).
So now all that's left is the inserts. But when I execute the contents of the dump file as a mysql query it doesn't insert the data.
When I copy and paste the dump file contents and insert them in phpmyadmin's query box, there's no problem - they insert perfectly.
Does anyone know why this is working from my script please?
Here's the code:
mysqldump -u -p Database table1 > $dump_filename -t -c
- this provides a file with just the inserts
I then grab the contents of this file
$file_contents = get_file_contents ($dump_filename);
// strip away the mysql header info - 1st occurrence of treble line break:
$str_pos = strpos($file_contents, "\n\n\n");
$file_contents = substr($file_contents, $str_pos + 3);
// insert the results
$mysql->performQuery("$file_contents");
I've tried trimming the query but this doesn't work either.
Please help and thanks...
Jason