thaidomizil Posted September 29, 2011 Share Posted September 29, 2011 Hello i want to fetch the content from my MySQL db for one table and show it on a page, i'm using this code: <?php include("inc/connect.php"); ?> <?php $result = $_REQUEST['result']; ?> <?php $query = mysql_query("select * from listtest order by id asc"); while($result = mysql_fetch_array($query)) { ?> <tr> <td><?php echo $result['id']; ?></td> <td><?php echo $result['code']; ?></td> <td align="center"><a href="edit.php?id=<?php echo $result['id']; ?>">View</a></td> <td align="center"> </td> </tr> <?php } ?> it's throwing me this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in 32qgtf.php on line 30 What am i doing wrong ? /Edit: line 29/30 is the mysql query / fetch. Quote Link to comment https://forums.phpfreaks.com/topic/248138-fetch-mysql-content-error/ Share on other sites More sharing options...
mikesta707 Posted September 29, 2011 Share Posted September 29, 2011 It seems like your query is failing. Try changing your query line to $query = mysql_query("select * from listtest order by id asc") or die(mysql_error()); and post if there is an error (and what the error is) Note: or die() is never good to use in production. its ok for debugging purposes only. Quote Link to comment https://forums.phpfreaks.com/topic/248138-fetch-mysql-content-error/#findComment-1274199 Share on other sites More sharing options...
thaidomizil Posted September 29, 2011 Author Share Posted September 29, 2011 I changed the query line, the result is the same, no more specific error is given. Quote Link to comment https://forums.phpfreaks.com/topic/248138-fetch-mysql-content-error/#findComment-1274205 Share on other sites More sharing options...
mikesta707 Posted September 29, 2011 Share Posted September 29, 2011 is there anything in your database? Quote Link to comment https://forums.phpfreaks.com/topic/248138-fetch-mysql-content-error/#findComment-1274208 Share on other sites More sharing options...
cunoodle2 Posted September 29, 2011 Share Posted September 29, 2011 If you have phpmyadmin log into there, select your table and then in the mySql box copy and paste the query in.. "select * from listtest order by id asc" What happens? Any results? What if you View>Source of the page. Is anything showing up then? It could be you have an issue with your html Quote Link to comment https://forums.phpfreaks.com/topic/248138-fetch-mysql-content-error/#findComment-1274221 Share on other sites More sharing options...
PFMaBiSmAd Posted September 29, 2011 Share Posted September 29, 2011 I'm going to guess that in your actual code, you are overwriting the result resource that is in $query, inside of the loop. Is that the actual complete code that is inside the while(){} loop? Quote Link to comment https://forums.phpfreaks.com/topic/248138-fetch-mysql-content-error/#findComment-1274222 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.