我对这段代码的错误感到厌烦:这是我准备的代码,稍后会从表单中获取用户输入。现在,我正在尝试完善插入代码。
<?php
$mysqli = new mysqli("connection info here");
// Check connection
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
/* Create a prepared statement */
if($stmt = $mysqli -> prepare("insert into carpool(Destination, No_of_seats_available) values(?,?)"))
{
/* Bind parameters
s - String, b - Boolean, i - Integer etc */
$Destination='vishal';
$No_of_seats_available=25;
$stmt -> bind_param("si", $Destination, $No_of_seats_available);
/* Execute it */
$result=$stmt -> execute();
$rowsAffected = $stmt->affected_rows;
if($result > 0){
echo "Rows Affected: ".$rowsAffected;
}
else{
echo 'Sorry, Please try after some time';
}
}
mysqli_close($mysqli);
?>
我收到“抱歉,请稍等一会儿”错误。我认为这意味着直到该行代码的所有代码都被正确执行了?我检查了表和字段名称,所有都正确匹配。但是,表中没有插入并显示错误。 我错过了什么?