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

  • Home
  • SEARCH
  • 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 972207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:05:14+00:00 2026-05-16T03:05:14+00:00

I am having trouble with the query in this code. The problem is one

  • 0

I am having trouble with the query in this code. The problem is one I have had before, the $num = mysql_num_rows($result); part gives me a MySQL error saying it expected a resource. Usually when I have this error it is because I misplaced a single quote some where, but after looking I cannot find any problem, though this query is a bit more complex than what I usually have to deal with.

//connect to the database and stuff

$last_year = idate("Y")-1;
$month = date("m");
$day = date("d");                                   

$query = "SELECT bills.b_id, bills.c_id, bills.grand_total, bills.void, bills.date_added,
                 customers.b_name, customers.l_name, customers.f_name, customers.phone 
          FROM bills, customers 
          WHERE bills.c_id = customers.c_id 
                AND bills.void = '0' 
                AND date_added BETWEEN '".$last_year."-".$month."-".$day."' AND CURDATE()";
$result = mysql_query($query);
mysql_close($link);                 
$num = mysql_num_rows($result);

EDIT:

Although I already know the mysql_close() function is not the problem I went ahead and removed it and my code still does not work. This EXACT same code (other than the query) works in nearly a dozen other pages. The problem is in the query, the MySQL error (as stated before) is mysql_num_rows() expects parameter 1 to be resource. I am working on getting the specific error now.

  • 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-16T03:05:15+00:00Added an answer on May 16, 2026 at 3:05 am

    Add some error handling to your code.

    $result = mysql_query($query);
    if ( !$result ) {
      echo 'the query failed: ', mysql_error();
      die;
    }
    

    (in “real” production code you might not want to display the actual query and error message to just any arbitrary user though).

    see also: http://docs.php.net/mysql_error

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

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer We use Integrity. It is a pretty simple solution -… May 16, 2026 at 3:58 pm
  • Editorial Team
    Editorial Team added an answer Never used TI-Basic... but how about also storing a 2D… May 16, 2026 at 3:58 pm
  • Editorial Team
    Editorial Team added an answer Short answer: no, it can't be done. Doing this would… May 16, 2026 at 3:58 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm having trouble executing a Doctrine DQL Query. This is the error it gives
Having a little bit of trouble with this section of code: if(!empty($_POST['RemoveRequest']) && isset($_POST['RemoveRequest'])){
I'm having trouble building an Entity Framework LINQ query whose select clause contains method
I'm having a little bit of trouble understanding what the problem is here. I
I'm having trouble with a query I'm trying to do. I'm trying to select
I'm having trouble working out a query. I've tried subqueries, different joins and group_concat()
This is for Entity Framework for .NET 3.5: I have the need to query
I am having trouble getting my model manager to behave correctly when using the
Having some trouble with what should be a very simple scenario. For example purposes,
I've been having some trouble using an IN in a where clause using MySQLi

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.