Page 1 of 1

invalid mySQL result source

Posted: Wed Aug 13, 2003 11:02 am
by esau
im troubleshooting some php code that i did not write. the code is a simple ordering system that interfaces with a mySQL db. any help would be greatly appreciated.

here is the error that i am getting:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/foxhollo/public_html/Nathan Code/displayorders.php on line 14


here is line 14:

Code: Select all

$orders = mysql_query("SELECT DISTINCT * FROM fhforders ORDER BY ordernumber");
i believe the problem is with 'fhforders'. this is supposed to be a table in a .db file, correct? yet i see no mention of fhforders anywhere else, except when it is referenced in the above fashion.

and here is the .php file that contains the code:

Code: Select all

<?php 
include("top.inc"); 

if(isset($tobedeleted))&#123; 
mysql_query("DELETE FROM fhforders WHERE ordernumber="$tobedeleted""); 
&#125; 

echo("<table align="center" width="600" bgcolor="#333333" border="3" bordercolor="black" cellspacing="0" cellpadding="3">" . 
"<tr bgcolor="#666666"><td><b>Order Number</b></td><td><b>username</b></td><td><b>item number</b></td><td><b>date</b></td><td></td></tr>"); 

$tempcheck = "do not confuse me"; 

$orders = mysql_query("SELECT DISTINCT * FROM fhforders ORDER BY ordernumber"); 
while ($row = mysql_fetch_array($orders)) 
&#123; 
$ordernumber = $row&#1111;"ordernumber"]; 
$username = $row&#1111;"username"]; 
$itemnumber = $row&#1111;"itemnumber"]; 
$material = $row&#1111;"material"]; 
$quantity = $row&#1111;"quantity"]; 
$date = $row&#1111;"date"]; 


if($tempcheck!=$ordernumber) 
&#123; 
echo("<tr><td><a href="displayorder.php?checking=$ordernumber">$ordernumber</a></td><td>$username</td><td>$itemnumber</td><td>$date</td><td><a href="$PHP_SELF" . "?tobedeleted=$ordernumber">delete</a></td></tr>"); 
&#125; 

$tempcheck=$ordernumber; 
&#125; 

echo("</table>"); 

include("bottom.inc"); 
?>

Posted: Wed Aug 13, 2003 4:20 pm
by JayBird
You didn't actually make a connection to the database, unless it was done in the "top.inc" file that is included.

Mark