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>";
}
?>

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.