请帮我解决这个问题:
mysqli_query()期望在第24行上给出.......至少2个参数1
mysqli_query()期望在第24行上给出.......至少2个参数1
mysqli_query()期望在第24行上给出.......至少2个参数1
<?php
if (isset($_POST['submit']))
{
$db_server = "localhost";
$db_user = "root";
$db_pass = "";
$db_name = "rms_db";
$db = new mysqli($db_server, $db_user, $db_pass, $db_name);
if($db->connect_errno){
echo "Could not connect to database";
}
//Import uploaded file to Database
$file_CSV = fopen($_FILES['filename']['tmp_name'], "r");
while (($data = fgetcsv($file_CSV, 1000, ",")) !== FALSE) {
mysqli_query("INSERT into stinfo (ibsn, name, ftname,mtname, sex, birth,religion, nationality, phone,email, bio, address, joined)
values('$data[0], '$data[1]', '$data[2]','$data[3]','$data[4]', '$data[5]', '$data[6]','$data[7]', '$data[8]', '$data[9]','$data[10]', '$data[11]', NOW())");
}
fclose($file_CSV);
//print "Import done";
echo "<script type='text/javascript'>alert('Successfully Imported a CSV File for User!');</script>";
echo "<script>document.location='index.php'</script>";
//view upload form
}
?>
答案 0 :(得分:1)
您已在此处创建了一个MySQLi对象$db
:
$db = new mysqli($db_server, $db_user, $db_pass, $db_name);
你在这里使用过它:
if($db->connect_errno){
所以在这里使用它:
$db->query("INSERT into stinfo (ibsn, name, ftname, mtname, sex, birth, religion, nationality, phone, email, bio, address, joined)
values ('$data[0], '$data[1]', '$data[2]', '$data[3]','$data[4]', '$data[5]', '$data[6]', '$data[7]', '$data[8]', '$data[9]', '$data[10]', '$data[11]', NOW())");
答案 1 :(得分:0)
您忘记在$db
mysqli_query($db, <your request>)