Darkmatter5 Posted October 7, 2008 Share Posted October 7, 2008 Here's my code <?php include 'library/config.inc.php'; mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbnamemain); $query="SELECT cabinet_id, cab_name, cab_description FROM $dbnamemain.cabinets ORDER BY cab_name ASC"; $result=mysql_fetch_array($query) or die($query . '<br >'.mysql_error()); //while(list($cabinet_id, $cab_name, $cab_description)=mysql_fetch_array($query, MYSQL_NUM)) { foreach ($result as $row) { $cabinet=$cab_name. ": " .$cab_description; echo "<tr> <td width='200'>" .substr($cabinet,0,100). "</td> <td width='100' align='center'><a href='cab_edit.php?cab_id=$cabinet_id'>edit </a> | <a href='javascript:delArticle('$cabinet_id','$cab_name');>delete</a>,/td> </tr>"; } mysql_close($conn); ?> Here's the error it's producing. "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/thealien/public_html/ecabinet/testing.php on line 9 SELECT cabinet_id, cab_name, cab_description FROM thealien_ecabinet.cabinets ORDER BY cab_name ASC". How can I fix this? Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 7, 2008 Share Posted October 7, 2008 You need to RUN the query first! include 'library/config.inc.php'; mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbnamemain); $query="SELECT cabinet_id, cab_name, cab_description FROM $dbnamemain.cabinets ORDER BY cab_name ASC"; //Run the querey $result=mysql_query($query) or die (mysql_error()); //$result = mysql_fetch_array($query) while(list($cabinet_id, $cab_name, $cab_description)=mysql_fetch_array($result, MYSQL_NUM)) { foreach ($result as $row) { $cabinet=$cab_name. ": " .$cab_description; echo "<tr> <td width='200'>" .substr($cabinet,0,100). "</td> <td width='100' align='center'><a href='cab_edit.php?cab_id=$cabinet_id'>edit </a> | <a href='javascript:delArticle('$cabinet_id','$cab_name');>delete</a>,/td> </tr>"; } mysql_close($conn); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.