Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
will83
- Forum Commoner
- Posts: 53
- Joined: Thu Nov 10, 2005 3:13 pm
Post
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
-
Zoxive
- Forum Regular
- Posts: 974
- Joined: Fri Apr 01, 2005 4:37 pm
- Location: Bay City, Michigan
Post
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
-
John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
-
Contact:
Post
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.