Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7407431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:43:12+00:00 2026-05-29T05:43:12+00:00

I have this query in my PHP: <?php $comments_list = mysql_query(SELECT * FROM comments

  • 0

I have this query in my PHP:

<?php
$comments_list = mysql_query("SELECT * FROM comments ORDER BY `date` DESC, `time` DESC LIMIT 5");
echo mysql_error();
if (mysql_num_rows($comments_list) != 0)
{
    echo('<ul>');
    while ($comment = mysql_fetch_array($comments_list))
    {
        echo('<li>'.substr($comment['content'],0,70).'</li>');
    }
    echo('</ul>');
}
else
{
    echo('<center>No comment.</center>');
}
?>

And it gives this error if my table is empty:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-5.3.9\www\admin\index.php on line 101

EDIT: I was querying LIMIT 5 before the ORDER BY. Now it’s fixed and I added the echo mysql_error() as edited in the question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:43:13+00:00Added an answer on May 29, 2026 at 5:43 am

    Because $comments_list is false, use mysql_error() to see what is wrong.

    $comments_list = mysql_query("SELECT * FROM comments LIMIT 5 ORDER BY `date` DESC, `time` DESC");
    if (!$comments_list ) {
        die('Invalid query: ' . mysql_error());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried this code: <?php $sql=SELECT id, comment FROM comments ORDER BY comments.id
So i have this script: <?php $query = mysql_query( SELECT meetup AS text, id
I have this PHP code: $query = SELECT name, COUNT(message) FROM guestbook_message WHERE name='.$req_user_info['username'].'
I have this query: SELECT page.id, revision.title, revision.number FROM page INNER JOIN revision ON
I have a query like this (Mysql 5.X, PHP - formatted for legibility) $query
I have this query in sql server 2000: select pwdencrypt('AAAA') which outputs an encrypted
I have this query in LINQ to Entities. var query = (from s in
I have this query this.FixturePartidoPuntaje.Load(); var partidos = from q in this.FixturePartidoPuntaje where (
I have this code: <?php $fql = SELECT url, normalized_url, share_count, like_count, comment_count, ;
I have a query that gets comments from a database and displays them based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.