This is part of my code
$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 "".$productName." added successfully! =)
";
}
I get the error Fatal error: Call to a member function bind_param() on a non-object on the line $stmt->bind_param("ssssssss", $productName, $picturecontent, $description, $category, $price, $uploadedDate, $sold , $sellerId); but i can't figure it out. Please help.
Answer
the query fail and dont return the prepared stament look,
VALUES(?,?,?,?,?,?,?.?)
change to
VALUES(?,?,?,?,?,?,?,?)
No comments:
Post a Comment