我是 mysqli 的新手,我已经检查了 PHP 手册等,没有任何效果。我不太确定出了什么问题。我不断收到此错误:
Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters in prepared statement in C:\xampp\htdocs\new1\template.php on line 165
还有这个
Warning: mysqli_stmt_affected_rows() [function.mysqli-stmt-affected-rows]: Couldn't fetch mysqli_stmt in C:\xampp\htdocs\new1\template.php on line 190
编码
$query = "INSERT INTO pets (name, age, gender, dob, breed_type, breed1, breed2, color, spay, size, hair_length, vaccine, vaccinated, dewormed, adoption_fees, aboutpet, petpic1, petpic2, petpic3) VALUES ('?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?')";
// PREPARE QUERY TO BE EXECUTED.
$stmt = $mysqli->prepare($query);
$stmt->bind_param("sssssssssssssssssss",$petname, $petage, $petgender, $petdob, $petbreedtype, $petbreed1, $petbreed2, $petcolor, $petspay, $petsize, $pethair, $petvaccine, $petvaccineamount, $petdewormed, $petadoptfees, $aboutpet, $target_path, $target_path1, $target_path2 );
$petname = $_POST['petname'];
$petage = $_POST['petage'];
$petgender = $_POST['petgender'];
$petdob = $_POST['petdob'];
$petbreedtype = $_POST['petbreedtype'];
$petbreed1 = $_POST['petbreed1'];
$petbreed2 = $_POST['petbreed2'];
$petcolor = $_POST['petcolor'];
$petspay = $_POST['petspay'];
$petsize = $_POST['petsize'];
$pethair = $_POST['pethair'];
$petvaccine = $_POST['petvaccine'];
$petvaccineamount = $_POST['petvaccineamount'];
$petdewormed = $_POST['petdewormed'];
$petadoptfees = $_POST['petadoptfees'];
$aboutpet = $_POST['aboutpet'];
//EXECUTE QUERY
$stmt->execute();
//CLOSE EXECUTE
$stmt->close();
$rowcount = mysqli_stmt_affected_rows($stmt);
if ($rowcount > 0)
{
echo "<div class='noerror'>Form has been submitted successfully!</div>";
}
请帮忙,我现在完全迷路了。