[SOLVED] mysql_num_rows(): is not a valid Mysql Result

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jwer78
Forum Newbie
Posts: 2
Joined: Wed Jun 30, 2004 3:39 pm

[SOLVED] mysql_num_rows(): is not a valid Mysql Result

Post by jwer78 »

I am trying to setup a script that searches in a database does calculations and posts the player of the game for a football league. I get this error though when the script has run Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\phpdev\www\rfl\update\load_pog.php on line 24
also on line 176 but the lines are the same exact code. The line is

Code: Select all

<?php
$num_rows = mysql_num_rows($res); 
?>
and the few lines before and after are

Code: Select all

<?php
$get_gameids = "select game_summary.game_id, home_team, home_final, away_team, away_final from game_teamstats, game_summary where game_teamstats.game_id=game_summary.game_id and league_id=$league_id and season=$season and week=$week and (home_total_offense+away_total_offense<625 or home_passing_tds+home_rushing_tds+away_passing_tds+away_rushing_tds<4 or home_turnovers+away_turnovers>4)";
    $res=mysql_query($get_gameids,$db);
    $num_gameids = mysql_num_rows($res);

    for($count=0;$count<$num_gameids;$count++){
        $game_id = mysql_result($res,$count,"game_id");
?>
I searched around for some answers in forums and manuals with not much luck.. probably cause im pretty ne to php and the manuals are just mumbo jumbo to me lol. If you have any ideas I would greatly appreciate them. Thanks ahead of time.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Try the tips here, especially the mysql_error() one. It should highlight the problem.
jwer78
Forum Newbie
Posts: 2
Joined: Wed Jun 30, 2004 3:39 pm

Post by jwer78 »

Wow that really helped. Now there is just one error which I think I can figure out. Thanks alot.
Post Reply