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

时间:2015-03-07 04:12:26

标签: php mysqli sqlbindparameter

$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()。请指教。谢谢你。

1 个答案:

答案 0 :(得分:0)

您在变量名称中输入了错误。

你有:

$stml =$conn->prepare ...

但它应该是:

$stmt =$conn->prepare ...