I have a SqlDump.sql file that works just fine when I apply it using the Import feature of phpMyAdmin, however I need to be able to accomplish this programmatically. Being a noob, I tried to do something like this:
$SQL=file_get_contents('SqlDump.sql');
$DB=mysqli_connect('localhost','root','');
mysqli_select_db($DB,'somedb');
if (mysqli_multi_query($DB, $SQL)) {
do {
if ($result = mysqli_store_result($DB)) {
mysqli_free_result($result);
}
} while (mysqli_next_result($DB));
}
$Err=mysqli_error($DB);
mysqli_close($DB);
But I get all kinds of mysql errors. Yet the same file works just fine when I import it using phpMyAdmin. How do I get this to work programmatically?
Error:
Can't create table 'somedb.t_sr_u_alertcode' (errno: 150)