Jump to content

[SOLVED] MySQL Errors


Irksome

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.