I am trying to select columns from 5 tables all from the same session id. However i am receiving this: Trying to get property 'num_rows' of non-object. Here's my code:
<?php
include 'db.php';
$sql = "SELECT users.username,
bank.cash_on_hand, bank.bank,
ranking.rank, ranking.level_points,
_location.location,
bullets.bullets, bullets.backfire
FROM users, bank, bank, ranking, ranking, _location, bullets, bullets
WHERE id = '".$_SESSION["id"]."' ";
$result = $conn->prepare($sql);
if($result-> num_rows > 0)
{
while ($row = $result-> fetch_assoc())
{
echo "<table>".
"<tr>
<th>username |</th>
<th>cash on hand |</th>
<th>bank |</th>
<th>rank |</th>
<th>level_points |</th>
<th>location |</th>
<th>bullets |</th>
<th>backfire </th>
</tr>".
"<tr>".
"<td>". $row["username"]. "</td>".
"<td>". $row["cash_on_hand"]. "</td>".
"<td>". $row["bank"]. "</td>".
"<td>". $row["rank"]. "</td>".
"<td>". $row["level_points"]. "</td>".
"<td>". $row["_location"]. "</td>".
"<td>". $row["bullets"]. "</td>".
"<td>". $row["backfire"]. "</td>".
"</tr>".
"</tr>".
"</table>";
}
}
else
{
echo "0 result";
}
?>
And i receive this error: Trying to get property 'num_rows' of non-object in C:\wamp64\www\phil\player_info_bar.php on line 27
& line 27 is this: if($result-> num_rows > 0)
How do i resolve this?