致命错误:在非对象上调用成员函数bind_param()

时间:2013-11-07 12:40:44

标签: php

这是我的代码的一部分

$con = mysqli_connect("localhost","root","","baspdata",3306);
if (mysqli_connect_errno())
{ 
echo "Error connecting to database: ".mysqli_connect_error();
exit();
}
else
{ 
$result=mysqli_query($con,"SELECT * FROM member WHERE Username='$username' and Password = '$password'");
$row=$result->fetch_assoc();
$sellerId=$row['MemberId'];
$picturecontent= file_get_contents($productPic);    
$query ="INSERT INTO product (ProductName, ProductPicture, ProductDescription, ProductCategory, ProductPrice, UploadedDate, Sold, SellerId) VALUES(?,?,?,?,?,?,?.?)";
$stmt=$con->prepare($query);
$stmt->bind_param("ssssssss", $productName, $picturecontent, $description, $category, $price, $uploadedDate, $sold , $sellerId);
$stmt->execute();
$con->close();
echo "<h1>".$productName." added successfully! =)<br/> </h1>"; 

}

我收到错误致命错误:在$ stmt-&gt; bind_param(“ssssssss”,$ productName,$ picturecontent,$ description,$ category,$)行上的非对象上调用成员函数bind_param()价格,$ uploadedDate,$ sold,$ sellerId);但我无法弄清楚。请帮忙。

1 个答案:

答案 0 :(得分:2)

查询失败,并且不返回准备好的语句外观,

VALUES(?,?,?,?,?,?,?.?)

更改为

VALUES(?,?,?,?,?,?,?,?)