Hi everyone,
I'm having eerors with my php code and here's the errror code that i'm recieving:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/w0638385/public_html/blog/index.php on line 9
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/w0638385/public_html/blog/index.php on line 22 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/w0638385/public_html/blog/index.php on line 29
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/w0638385/public_html/blog/index.php on line 41
Here's my php code:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL & ~E_NOTICE);
require("header.php");
$sql= "SELECT entries.*, categories.cat FROM entries, categories WHERE entries.cat_id = categories.id ORDER BY dateposted DESC LIMIT 1;";
$result = mysqli_query($db,$sql);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
echo "<h2 id='title'> <a href='viewentry.php?id=" .$row['id']. "'>" . $row['subject'] . "</a></h2><br />";
echo "<p id='byline'>In <a href='viewcat.php?id=" .$row['cat_id'] . "'>" . $row['cat'] . "</a> - Posted on<span class='datetime'>" . date("D jS F Y g.iA",strtotime($row['dateposted'])) . "</span></p>";
echo "<p>";
echo nl2br($row['$body']);
echo "</p>";
// Comments on this blog entry:
echo "<p id='coments'>";
$commsql = "SELECT name FROM comments WHERE blog_id =" . $row['id'] . " ORDER BY dateposted;";
$commresult = mysqli_query($db, $commsql);
$numrows_comm = mysqli_num_rows($commresult);
// Begin If statement
if ($numrows_comm === 0) {
echo "(<strong>" .$numrows_comm . "</<strong>) comments : ";
$i = 1;
}else{
while ($commrow = mysqli_fetch_array($commresult, MYSQLI_ASSOC)) {
echo "<a href='viewentry.php?=" . $row['id'] ."#comment" . $i . "'>" .$commrow['name'] . "</a>";
$i++;
}
}
echo "</p>";
// Display the previous 5 blog entries:
$prevsql = "SELECT entries.* ,categories.cat FROM entries, categories WHERE entries.cat_id = categories.id ORDER BY dateposted DESC LIMIT 1, 5;";
$prevresult = mysqli_query($db, $prevsql);
$numrows_prev = mysqli_num_rows($prevresult);
echo "<div id='prev'>";
if($numrows_prev == 0) {
echo "<p>No previous entries.</p>";
}
else{
echo "<ul>";
while ($prevrow = mysqli_fetch_array($prevresult, MYSQLI_ASSOC)) {
echo "<li> <a href='viewentry.php?id=" . $prevrow['id'] . "'>" . $prevrow['subject'] ."</a></li>";
}
echo "</ul>";
}
echo "</div>";
require("footer.php");
?>
What am i doing wrong?