警告:mysqli_stmt_close()要求参数1为mysqli_stmt,给定布尔值
我收到了这个错误,不知道为什么,花了3个小时来检查所有内容而无法找到问题
// Prepare a select statement
$sql = "SELECT countries.name AS country_name, customers.id, customers.name AS customer_name, surname, phone, email, address1, code FROM customers WHERE id = ? JOIN countries ON country_code = code";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $param_id);
// Set parameters
$param_id = trim($_GET["id"]);
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
$result = mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($result) == 1){
/* Fetch result row as an associative array. Since the result set
contains only one row, we don't need to use while loop */
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
// Retrieve individual field value
$name = $row["customer_name"];
$address1 = $row["address1"];
$salary = $row["code"];
} else{
// URL doesn't contain valid id parameter. Redirect to error page
header("location: error.php");
exit();
}
} else{
echo "Oops! Something went wrong. Please try again later.";
}
}
// Close statement
var_dump($stmt);
mysqli_stmt_close($stmt);
// Close connection
mysqli_close($link);}