how to import .sql file in mysql databse with php

mysqli, php

Solution

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);

Problem

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.

Original source

Related problems