Finker92 Posted January 9, 2012 Share Posted January 9, 2012 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/254635-this-was-working-but-now-its-notplease-why/ Share on other sites More sharing options...
trq Posted January 9, 2012 Share Posted January 9, 2012 What changed? Quote Link to comment https://forums.phpfreaks.com/topic/254635-this-was-working-but-now-its-notplease-why/#findComment-1305693 Share on other sites More sharing options...
Finker92 Posted January 9, 2012 Author Share Posted January 9, 2012 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" Quote Link to comment https://forums.phpfreaks.com/topic/254635-this-was-working-but-now-its-notplease-why/#findComment-1305696 Share on other sites More sharing options...
Muddy_Funster Posted January 9, 2012 Share Posted January 9, 2012 It's not retrieving a result set from the database. use error capture to get the mysql error for each query and that will help identify your problem. If you need more help post the error you get in here. Quote Link to comment https://forums.phpfreaks.com/topic/254635-this-was-working-but-now-its-notplease-why/#findComment-1305697 Share on other sites More sharing options...
PFMaBiSmAd Posted January 9, 2012 Share Posted January 9, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/254635-this-was-working-but-now-its-notplease-why/#findComment-1305738 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.