I'm trying to import .sql file into mysql database using php but I can't
Am using like this code:
<?php
$sql = mysqli_connect('localhost', 'root', '123123', '');
mysqli_query($sql, "USE vmail");
mysqli_query($sql, "source insert.sql");
mysqli_close($sql);
echo ("Done")
?>
How can I import it??
thnx.
Try this code. You have to read the sql file first and than execute:
eg:
$sqlSource = file_get_contents('insert.sql');
mysqli_multi_query($sql,$sqlSource);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With