Page 1 of 1

Database help

Posted: Thu Nov 17, 2005 3:48 pm
by will83
Hi I'm getting the error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\phpdev5\www\tracking\display-contents.php on line 20

From this code:

Code: Select all

<?php  

include 'connect.php'; 

$company = $_POST['company']; 

echo "Results for ".$company."<br /><br />"; 

$query = mysql_query("SELECT * FROM link_log WHERE link_log.company_id = link_company.id;"); 

echo "<table cellspacing=\"0\" cellpadding=\"0\">\n"; 

echo "<tr>\n"; 

while($row = mysql_fetch_array($query)) { 
echo "<td>".$company."</td><td>$row[date]<\td>\n"; 
} 

echo "</tr>\n"; 

echo "</table>\n"; 

?>


Can anyone spot what is wrong with this?

Thanks for your help.

Will

Posted: Thu Nov 17, 2005 5:14 pm
by Zoxive
Try adding a Die for the Query, see if somethings wrong with the query,

Code: Select all

$query = mysql_query("SELECT * FROM link_log WHERE link_log.company_id = link_company.id;") or die('Query failed: ' . mysql_error());
-NSF

Posted: Thu Nov 17, 2005 5:15 pm
by John Cartwright
change

Code: Select all

$query = mysql_query("SELECT * FROM link_log WHERE link_log.company_id = link_company.id;");
to

Code: Select all

$query = mysql_query("SELECT * FROM link_log WHERE link_log.company_id = link_company.id;") or die(mysql_error());
to see why your query is failing.