Jump to content

please explain error


webguync

Recommended Posts

I get this error when trying to display data from a MySQL table

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/content/n/c/u/ncupsetbids/html/templates/RecordManagementTemplate.php on line 11

 

does this just mean no results are being found?

 

here is the PHP code

 

$result=mysql_query ("SELECT * from upsetsbids   ORDER BY HearingID ");
$resultCount = mysql_num_rows($result);
if ($resultCount > 0)   {  // make sure we have data to display

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/98232-please-explain-error/
Share on other sites

No, usually that means there is a problem with your query. To see why your query is failing, add or die(mysql_error()) at the end of the mysql_query call, eg:

$result=mysql_query ("SELECT * from upsetsbids   ORDER BY HearingID ") or die(mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/98232-please-explain-error/#findComment-502606
Share on other sites

to take it one step further you should write queries like

<?php
$q = "Select * from `upsetbids` order by HearingID";
$r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
?>

 

That is proper way to debug a query because when it splashes out a mysql error it will also splash out the outputted query so you can quickly see the mistake or take said query into phpmyadmin and modify it to work better as is all to often the case.

Link to comment
https://forums.phpfreaks.com/topic/98232-please-explain-error/#findComment-502609
Share on other sites

thanks,

 

thanks another error now

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/n/c/u/ncupsetbids/html/templates/RecordManagementTemplate.php on line 29

 

and the current code from line 29:

while ($row = mysql_fetch_assoc($q)) {  // Display the data from mysql

 

Link to comment
https://forums.phpfreaks.com/topic/98232-please-explain-error/#findComment-502619
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.