Hello I am having trouble with a select statement, mysqli_prepare returns a boolean value. I get the response " mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given"
I have a similar code that works so I can't find my error. Here is my code:
$mailUser = $_POST["mailUser"];
$statement = mysqli_prepare($con, "SELECT store.name, product.name, location.hall, location.price FROM location INNER JOIN product ON product.id = location.idProduct INNER JOIN store ON store.id=location.idStore WHERE mailUser= ?");
mysqli_stmt_bind_param($statement, "s", $mailUser);
mysqli_stmt_execute($statement);
Also, I am trying to update a value using php variables, it doesn't show any error but the values aren't updated
$statement = mysqli_prepare($con, "UPDATE product SET description='.$description.', brand='.$brand.', altBrand='.$altBrand.', quant='.$quant.', quantToday='.$quantToday.' WHERE name='.$name.' AND mailUser='.$mailUser.'");
mysqli_stmt_execute($statement);
---EDIT--- I managed to solve the second problem by changing my code to this:
$statement = mysqli_prepare($con, "UPDATE product SET description=?, brand=?, altBrand=?, quant=?, quantToday=? WHERE mailUser = ? and name = ?"); mysqli_stmt_bind_param($statement, "sssssss", $description, $brand, $altBrand, $quant, $quantToday, $mailUser, $name); mysqli_stmt_execute($statement);