I cannot work out why I am receiving this error:
mysql_fetch_assoc() expects parameter 1 to be resource, boolean given on line 32
I have tried searching for the answer but have had no such luck.
I am self taught learning to code and any help would be greatly appreciated.
<table>
<thead>
<tr>
<td>First Name</td>
<td>Last Name</td>
<td>Email</td>
</tr>
</thead>
<tbody>
<?php
$mysql_host = 'localhost';
$mysql_user = 'root';
$mysql_pass = '';
mysql_connect($mysql_host, $mysql_user, $mysql_pass);
/* #1 get properties and it's data */
$seller_id="SELECT id FROM seller WHERE coupon_id='ab2345'" or die(mysql_error());
$property="SELECT bedrooms, bathrooms, parking FROM property WHERE seller_id='{$seller_id}'" or die(mysql_error());
$results = mysql_query($property);
/* #2 store property data in variable */
$property_row = mysql_fetch_assoc($results);
$bathrooms = $property_row['bathrooms'];
$bedrooms = $property_row['bedrooms'];
$parking = $property_row['parking'];
/*#3 get buyers (& their data) using property data as inputs */
$buyers="SELECT * FROM buyers WHERE bedrooms={$bedrooms} AND bathrooms={$bathrooms} AND parking={$parking}" or die(mysql_error());
$results = mysql_query($buyers);
/* #4 loop through buyers */
if (mysql_num_rows($results) < 1) echo "Oh no it seems like their are no buyers for your property"; else {
while ($row = mysql_fetch_assoc($results)) {
?>
<tr>
<td><?php echo $row['f_name']?></td>
<td><?php echo $row['l_name']?></td>
<td><?php echo $row['email']?></td>
</tr>
<?php
}
}
?>
</tbody>
</table>