Irksome Posted July 19, 2007 Share Posted July 19, 2007 Hi all, I've just made a small admin script to manage the user accounts on my website. I get the following error whilst accessing the page however: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /public_html/com/admin/users.php on line 7 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /public_html/com/admin/users.php on line 9 The code for the page is below. To be honest I can't see what's wrong with it: <?php // load the configuration file. include '../db.php'; $result = mysql_query("SELECT * FROM com_users ORDER BY userid DESC",$connect); while($myrow = mysql_fetch_assoc($result)) {//begin of loop //now print the results: echo $myrow['user_name']; echo "<a href=\"edit_user.php?userid=$myrow[userid]\">Edit User</a>"; }//end of loop ?> Any help on this would be very much appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/60848-solved-mysql-errors/ Share on other sites More sharing options...
pocobueno1388 Posted July 19, 2007 Share Posted July 19, 2007 It means there is something wrong with your query. Change this line: $result = mysql_query("SELECT * FROM com_users ORDER BY userid DESC",$connect); To: $result = mysql_query("SELECT * FROM com_users ORDER BY userid DESC",$connect)or die(mysql_error()); That will tell you what the problem is. Link to comment https://forums.phpfreaks.com/topic/60848-solved-mysql-errors/#findComment-302737 Share on other sites More sharing options...
jvrothjr Posted July 19, 2007 Share Posted July 19, 2007 Guess is its not connecting to the DB Link to comment https://forums.phpfreaks.com/topic/60848-solved-mysql-errors/#findComment-302739 Share on other sites More sharing options...
akitchin Posted July 19, 2007 Share Posted July 19, 2007 what it means is that you're not properly connecting to the database. you're either assigning the result of mysql_connect() to the wrong variable (one not named $connect), or the connection itself is failing. check db.php for where it's going wrong. EDIT: jvroth beat me to it, but i'm leaving it here. my fingers didn't work for nothing. Link to comment https://forums.phpfreaks.com/topic/60848-solved-mysql-errors/#findComment-302741 Share on other sites More sharing options...
Irksome Posted July 19, 2007 Author Share Posted July 19, 2007 Ahh that solved it! Thanks for the quick responses guys. Link to comment https://forums.phpfreaks.com/topic/60848-solved-mysql-errors/#findComment-302746 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.