atticus Posted December 17, 2007 Share Posted December 17, 2007 I am getting an error from the following code <?php include("config.php"); $sql = "SELECT clients.*,company.company_name FROM client,company WHERE client.com_id = company.com_id ORDER BY company_name"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo "<div class=\"result\"><h4>".$row['company_name']." </h4><br /><a href=\"com_editor.php?com_id=$row[com_id]\">Edit Company</a> | <a href=\"com_delete.php?com_id=$row[com_id]\">Delete Company</a><br />"; echo "<label>Name:</label> ".$row['lastname'].", ".$row['firstname']."<br /> "; echo "<label>User Name:</label> ".$row['username']."<br /> </div>"; error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in line: while($row = mysql_fetch_array($query)) { Link to comment https://forums.phpfreaks.com/topic/82059-solved-mysql-join-problem/ Share on other sites More sharing options...
revraz Posted December 17, 2007 Share Posted December 17, 2007 Count how many records were returned before doing your array. Also, add a error report after the query to make sure it was accepted. Link to comment https://forums.phpfreaks.com/topic/82059-solved-mysql-join-problem/#findComment-416988 Share on other sites More sharing options...
revraz Posted December 17, 2007 Share Posted December 17, 2007 Also, should clients be client here? SELECT clients.*, <---- Link to comment https://forums.phpfreaks.com/topic/82059-solved-mysql-join-problem/#findComment-416992 Share on other sites More sharing options...
atticus Posted December 17, 2007 Author Share Posted December 17, 2007 thanks...I did find the query was not working because of a typo... Link to comment https://forums.phpfreaks.com/topic/82059-solved-mysql-join-problem/#findComment-417011 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.