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