I am trying to write a script that displays blogposts from an SQL server on a webpage. I am reusing the script from an old project that does mostly the same thing where it works perfectly. In this new project, it does not work at all and gives me the error in the title. I have removed my pagination and sorting scripts from my code for the sake of ease of reading:
<?php
include('./includes/header.html');
require('mysqli_connect.php');
//If a user name is entered display login mesage
if (isset($_SESSION['fname'])) {
echo "You are currently logged in as {$_SESSION['fname']}. Welcome to our website!";
}
echo "<div align=\"center\">";
echo "<h2>Our wonderful comments</h2>";
echo "<br />";
echo '<table align="left" cellspacing="0" cellpadding="1" width="75%">
<tr>
<td align="center"><b><a href="index.php?sort=ln">Last Name</a></b></td>
<td align="center"><b><a href="index.php?sort=fn">First Name</a></b></td>
<td align="center"><b><a href="index.php?sort=date">Date</a></b></td>
</tr>
';
//This is our SELECT query
$query = "SELECT * FROM blogposts ORDER BY $order_by LIMIT $start, $display";
$results = mysqli_query ($dbc, $query);
/*This takes the query and loads it into an array and
outputs the results to our nicely formatted table */
while ($row = mysqli_fetch_array($results, MYSQLI_ASSOC)) {
echo '<table width="80%" border="1">
<tr>
<td colspan="2"><div align="center"><strong>' . $row['title'] . '</strong></div></td>
</tr>
<tr>
<td width="250"></td>
<td rowspan="5">' . $row['post'] . '</td>
</tr>
<tr>
<td><a href="comments.php?id=' . $row['blogid'] . '</td>
</tr>
<tr></tr>
</table>
<br/>
<hr width="70%">
<br/>';
}
mysqli_close($dbc);
include('./includes/footer.html');
?>
What this code SHOULD be doing is displaying data from the row 'title', 'post' and 'blogid' and displaying them. It does not do this and throws the error in the title. I feel like I am missing something simple here. If it helps, here is my server table structure: https://i.stack.imgur.com/2HxMX.png