Jump to content

num_rows argument not valid? HELP!


Immortal55

Recommended Posts

This is the error that I keep getting....


[b]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/theblizz/public_html/whitedevil/calendertest.php on line 13[/b]

I do not understand, I even copied the code from the page and pasted it and it still is giving me this error!

Here is the code (I know I spelled calendar wrong, but that is how it is.):

PHP code:
[code=php:0]

function getEventDays($month, $year) {
  $days = array();
  $sql = mysql_query("SELECT DAY(event_date) AS day, COUNT(event_id) FROM calender_events WHERE MONTH(event_date) = " . $month . " AND YEAR(event_date) = " . $year . " GROUP BY day");

  if (mysql_num_rows($sql) > 0) {
  while ($row = mysql_fetch_array($sql)) $days[] = $row['day'];
  }

  return $days;
    }

[/code]


One last thing the $_GET where exactly is it getting the year and month from???

Thank you in advance.

Also, this is all pertaining to the ([url=http://www.phpfreaks.com/tutorial_cat/29/Calendars--Date-&-Time.php]http://www.phpfreaks.com/tutorial_cat/29/Calendars--Date-&-Time.php[/url]) calendar tutorial here on the PHP freaks website.
Link to comment
Share on other sites

Ah, thank you for that.

That got me over one hurdle, but now I am getting an SQL error:

[b]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(event_date) AS day, COUNT(event_id) FROM calender_events WHERE[/b]

What in the world should I change there, as far as I know that should be perfect...
Link to comment
Share on other sites

[quote author=jesirose link=topic=124194.msg514235#msg514235 date=1169840743]
Do this:
$q = "SELECT DAY(event_date) AS day, COUNT(event_id) FROM calender_events WHERE MONTH(event_date) = " . $month . " AND YEAR(event_date) = " . $year . " GROUP BY day";
$sql = mysql_query($q)[b] OR die(mysql_error())[/b];

[/quote]

For this error I would change that because it's probably an error with the query's values.

$sql = mysql_query($q);
echo $q.'<br>'.mysql_query();

Once youve found the error, delete the second line. Always helps me find my errors.
Link to comment
Share on other sites

Well, that gave me more errors, now I have this one:

[b]
Warning: Wrong parameter count for mysql_query() in /home/theblizz/public_html/whitedevil/calendertest.php on line 14
SELECT DAY(event_date) AS day, COUNT(event_id) FROM calender_events WHERE MONTH(event_date) = 01 AND YEAR(event_date) = 2007 GROUP BY day
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/theblizz/public_html/whitedevil/calendertest.php on line 16[/b]
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.