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 8840925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:34:57+00:00 2026-06-14T10:34:57+00:00

I am getting an error when querying a table in my MySQL database. It’s

  • 0

I am getting an error when querying a table in my MySQL database. It’s the standard one with mysqli_num_rows when there is no value in the variable that’s being passed:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in folder/file.php on line 29

Problem is I can’t find the syntax error. I’ve looked at it a ton of times. Here’s what my code is:

$sql_messages = "SELECT * FROM messages WHERE to='$userid'";
$result_messages = $mysqli->query($sql_messages);
$num_rows_messages = mysqli_num_rows($result_messages);

I tried a fetch array but that gave me the similar error. Nothing is getting passed into $result_messages I suppose. I echo’ed out $userid and that has a value and I’ve checked my database and there is a table ‘messages’ with a field ‘to’. I’m connected to the right database because I have this code before this query:

$sql="SELECT * FROM users WHERE firstname='$firstname' && lastname='$lastname'";
$result = $mysqli->query($sql);
$row = mysqli_fetch_array($result);

And that works fine. It is the third query on the page, is there some sort of limit? Does anyone see a syntax error that I’m overlooking? Thanks, sorry if it’s a small little error!

  • 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-06-14T10:34:58+00:00Added an answer on June 14, 2026 at 10:34 am

    It’s because $mysqli->query() returned boolean FALSE, which, according to the mysqli::query() docs, it does when an error happens. You can get more detail on the error by accessing $mysqli->errno and $mysqli->error.

    I’m guessing that the root of the problem lies in the query which references a column called to, which is a MySQL reserved word. Try surrounding the word to in your query with backticks. Like this:

    $sql_messages = "SELECT * FROM messages WHERE `to`='$userid'";
    

    Really, though you should avoid naming columns and tables reserved words. Consider renaming the column if feasible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting error while inserting values into database (SQL Server 2008) Implicit conversion from data
I am getting error in the sql statement. (server= RAJ-PC\SQLEXPRESS; user id=sa; password=as64ws; database=onlineshopping,
i am getting error: cannot convert to pointer type NSMutableDictonary *mydictonary; [mydictionary setValue: [mySlider.value
i am getting an error while querying this select statement. $comments = dbgetvar(SELECT SUM(CASE
I'm having trouble querying my SQLite database using Android. I keep getting either an
I'm querying a database and some of the results I'm getting are null. I'm
I'm confused with MySQL. I'm querying a table with a primary key field called
I'm querying a Facebook public JSON feed. I'm getting an error: -[__NSCFString objectForKey:]: unrecognized
I am getting this error when I try to query the database and write
getting error while try to start service

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.