在提交表单时遇到此类错误: 致命错误:未捕获错误:在C:\ xampp \ htdocs \ rubina \ fuerte_developers_1 \ config.php:31中的bool上调用成员函数bind_param()堆栈跟踪:#0 {main}抛出在C:\ xampp \ htdocs \第31行的rubina \ fuerte_developers_1 \ config.php
我的config.php代码
<?php
session_start();
$fname= $_POST['fname'];
$lname= $_POST['lname'];
$email= $_POST['email'];
$area_code= $_POST['area_code'];
$phone= $_POST['phone'];
$method= $_POST['method'];
$cmpny = $_POST['cmpny'];
$service= $_POST['service'];
$contact= $_POST['contact'];
$amount= $_POST['amount'];
$currency= $_POST['currency'];
$des= $_POST['des'];
$website= $_POST['website'];
$conn = new mysqli('localhost', 'root','','creative');
if($conn->connect_error){
die('connection failed : ' .$conn->connect_error);
}
else{
$stmt = $conn->prepare("insert into creative(fname,lname,email,area_code,phone,method,cmpny,service,contact,amount,currency,des,website) values(?,?,?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bind_param("sssssssssssss", $fname,$lname,$email,$area_code,$phone,$method,$cmpny,$service,$contact,$amount,$currency,$des,$website);
$stmt->execute();
$stmt->close();
$conn->close();
}
$_SESSION["id"]=1;
header('location:index.php');
?>```
答案 0 :(得分:0)
该错误表示$stmt
不是您认为的那样。它不是对象-现在为false
,因为在准备语句时发生错误,这意味着SQL已关闭。
我的猜测是您的字段之一拼写错误(可能是cmpny
字段?)。