PHP:未定义的变量 & 调用非对象上的成员函数 bindParam()


PHP: undefined variable & Call to a member function bindParam() on a non-object

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$com_name=$_POST['com_name'];
$industry_ID=$_POST["industry"];
$email=$_POST["email"];
$con_num=$_POST["con_num"];
$ori_comname=$_POST["ori_com"];

$stml =$conn->prepare( "UPDATE client_info SET 
                    company_name=:com_name,
                    industry_ID=:industry_id,
                    email=:email,
                    contact_num=:cin_num 
                    WHERE company_name=:ori_com");
$stmt->bindParam(':com_name', "$com_name");
$stmt->bindParam(':industry_id', $industry_ID);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':cin_num', $con_num);
$stmt->bindParam(':ori_com', $ori_comname);
$stmt->execute();

我收到错误

未定义的变量,并在执行时调用非对象上的成员函数 bindParam()。

变量名称中键入错误。

你有:

$stml =$conn->prepare ...

但它应该是:

$stmt =$conn->prepare ...