0

i try this code to import a CSV file into my database but i got this error : Warning: mysqli::query(): Empty query

$db = new mysqli('localhost','root','', 'BD_Conference');


    $sql=mysql_query("INSERT INTO tbl_conference (pid, name,  chairs,keynote, abstract, speaker, affiliation, ville, pays, salle, date, time, session, image_url) VALUES ('','$champs1','$champs2','$champs3','$champs4','$champs5','$champs6','$champs7','$champs8','$champs9','$champs10','$champs11','$champs12','$champs13')");

    $result = $db-> query($sql) ;
Siraj
  • 67
  • 6
  • You already posted this http://stackoverflow.com/q/39308912/ and it was closed for the same reason; mixing MySQL APIs. Consult the link that both were closed with. – Funk Forty Niner Sep 03 '16 at 19:38

2 Answers2

2

check proper mysqli connection code should be

    $db= mysqli_connect('localhost','root','', 'BD_Conference');

   $sql=("INSERT INTO tbl_conference (pid, name,  chairs,keynote, abstract, speaker, affiliation, ville, pays, salle, date, time, session, image_url) VALUES ('','$champs1','$champs2','$champs3','$champs4','$champs5','$champs6','$champs7','$champs8','$champs9','$champs10','$champs11','$champs12','$champs13')");

        $result =  mysqli_query($db,$sql) ;
1

please use mysqli_query instead of mysql_query. So the connection is opened using mysqli.

$db = new mysqli('localhost','root','', 'BD_Conference');
if ($db->connect_errno) {
        echo "Errno: " . $mysqli->connect_errno . "\n";
}
$sql="INSERT INTO tbl_conference (pid, name,  chairs,keynote, abstract, speaker, affiliation, ville, pays, salle, date, time, session, image_url) VALUES ('','$champs1','$champs2','$champs3','$champs4','$champs5','$champs6','$champs7','$champs8','$champs9','$champs10','$champs11','$champs12','$champs13')";

$result = $db->query($sql) ;
Senthil
  • 2,156
  • 1
  • 14
  • 19