|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simple problem... I hope
I'm a total newbie using a very simple PHP script to pull nicknames and scores from a MySQL database, to display in an html scoreboard, but I'm getting an error message each time :-(
This is the piece of code that's causing the problem: $query = "SELECT nickname,score FROM sms_billiards ORDER BY score DESC limit 20"; $result = @mysql_query($query); $numPlayers = mysql_num_rows($result); for($count=0; $count<$numPlayers; $count++) { $nick = mysql_result($result,$count,"players"); $score = mysql_result($result,$count,"scores"); ?> <tr> <td width="40"> <div align="left"><b><font face="Verdana" size="2" color="#FFCC00"><?php echo($count+1); ?></font></b></div> </td> <td width="225"> <div align="left"><b><font face="Verdana" size="2" color="#FFCC00"><?php echo($nick); ?></font></b></div> </td> <td width="225"> <div align="left"><b><font face="Verdana" size="2" color="#FFCC00"><?php echo($score); ?></font></b></div> </td> </tr> <?php } ?> It keeps giving me the following message: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:dhoybinapachehtdocsrich2.php on line 112 Line 112 is the line: $numPlayers = mysql_num_rows($result); ANY help much appreciated. rich@mousebreaker.co.uk |
|
#2
|
|||
|
|||
|
RE: Simple problem... I hope
Have you selected a database? Either way,
try replacing: Code:
$result = @mysql_query($query); with this: Code:
$result=mysql_query($query) or die("MySQL Error No. ".mysql_errno().": ".mysql_error());
This will give you a description of what is wrong with you're query. |
|
#3
|
|||
|
|||
|
RE: Simple problem... I hope
Excellent. Identified the problem.
Thanks for your help :-) |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Simple problem... I hope |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|