This question already has an answer here:
I'm trying to update two tables from 1 form but it keeps on giving me this error
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\ethicaOak\public\prop.php on line 27
I'm sure that is not a problem to do just don't know why its giving me that error can some one help?
if (isset($_POST['submit'])){
$prop_title = $_POST['prop_title'];
$prop_summary = $_POST['summary'];
$prop_details = $_POST['prop_details'];
$prop_details = $_POST['category'];
$price = $_POST['price'];
$price_before = $_POST['price_before'];
$from = $_POST['from'];
$currency = $_POST['currency'];
$payment = $_POST['payments'];
$query = "UPDATE properties SET ";
$query .= "prop_title = '{$prop_title}' ";
$query .= "prop_summary = '{$prop_summary}' ";
$query .= "prop_details = '{$prop_details}' ";
$query .= "category = '{$category}' ";
$query .= "LIMIT 1 ";
$query .= "WHERE property_id = '{$manage_prop_id}'";
//{$manage_prop_id}
$result = mysqli_query($connection, $query);
$rows = mysqli_fetch_assoc($result);
$query = "UPDATE prop_price SET ";
$query .= "price = '{$price}' ";
$query .= "price_before = '{$price_before}' ";
$query .= "currency = '{$currency}' ";
$query .= "per_payment = '{$per_payment}' ";
$query .= "from_payment = '{$from_payment}' ";
$query .= "WHERE price_id = '{$manage_prop_id}'";
//{$manage_prop_id}
$result2 = mysqli_query($connection, $query);
$rows2 = mysqli_fetch_assoc($result2);
}else{
?>
<?php
$manage_prop_id = null;
if (isset($_GET['manage'])){
$manage_prop_id = $_GET['manage'];
}
else
{
$manage_prop_id = null;
}
?>
<input type="text" class="form-control" id="prop_title" name= "prop_title"
placeholder="Property Title" value ="<?php echo $rows['prop_title'];?>" >
<input type="text" class="form-control" name="summary" id="summary" placeholder="Property Summary" value = "<?php echo $rows['prop_summary'];?>">
<input type="text" class="form-control" id="price" name= "price" placeholder="Price of Property" value = "<?php echo $rows2['price'];?>">
</div>
You are defining your category as prop_details
$prop_details = $_POST['category'];
and trying to use a $category variable that doesn't exists
$query .= "category = '{$category}' ";
That way, your query could be failing and returning false.
Edit: As @Jaime said, update queries only return true or false, there's no way (and no reason) to fetch an update, since it doesn't return data.