Jump to content

This was working but now it's not.PLEASE WHY?


Finker92

Recommended Posts

This was working before but now it's not. Can anyone please, please tell me why?

<?php
require('pages/connection.php');
$latestposts= mysqli_query($connection,"SELECT title, content, post_number FROM blogposts ORDER BY timeofpost DESC LIMIT 9");//Query the database
while($displayposts=mysqli_fetch_array($latestposts)){ //go and get the information
echo "{$displayposts['title']}</br>";
echo "{$displayposts['content']}</br>";
echo "<a href='recentposts.php?id={$displayposts['post_number']}'>Read more</a></br>";
} 
?>

[code]
<?php
require('pages/connection.php');
$ID_number = $_GET['id'];
$content= mysqli_query($connection,"SELECT title, content, username FROM blogposts INNER JOIN users ON blogposts.author_id = users.user_id WHERE post_number='$ID_number'");
if(!$content){
echo mysqli_error();
echo "I am sorry but there was an error connecting to the server.";
}
while($singlepage=mysqli_fetch_array($connection, $content)){
extract($singlepage);
echo "<h3>$title</h3></br>";
echo "$content</br>";
echo "$username</br>";
}
?>

Not sure. I don't think that I changed anything - the variables are the same, GET_id is the same, etc. so can't figure. Could it be single quotes in the SELECT query? This is the error I'm getting "Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in C:\wamp\www\BlogProject\recentposts.php on line 9"

Your mysqli_fetch_array statement is invalid - $singlepage=mysqli_fetch_array($connection, $content)

 

It does not take the connection link as a parameter. It only takes the result resource (mysqli_result) from a mysqli_query() statement as a parameter.

 

Also, you have at least one mysqli_error() statement that does need the connection link as a parameter for it to work.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.