我尝试使用此代码将CSV文件导入我的数据库,但我收到此错误:警告:mysqli :: 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) ;
答案 0 :(得分:0)
请使用mysqli_query而不是mysql_query。所以使用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) ;
答案 1 :(得分:0)
检查正确的mysqli连接代码应该是
$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) ;