Re: mysql_query() problem
| From: | Girish Nath | Date: | Mon, 17 Dec 2001 11:42:36 +0000 |
| Subject: | Re: mysql_query() problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-77926@lists.php.net to get a copy of this message | ||
Hi
Try the following to find out what's happening :
$result = mysql_query($query,$conn) or die (mysql_error());
Or try echo'ing $result to see what it contains. It should contain something
like this if everything is working fine :
Resource id #2
Regards
Girish
----- Original Message -----
From: "Brian Rue" <rue@javagamz.com>
To: <php-general@lists.php.net>
Sent: Monday, December 17, 2001 8:33 AM
Subject: [PHP] mysql_query() problem
> Hi,
>
> I'm getting the error
> <<Warning: Supplied argument is not a valid MySQL result resource>>
>
> from this code:
>
> function validateUser($username,$password) {
> $conn = connectToMySQL();
> mysql_select_db($db_name,$conn);
> $query="select * from members where username='".$username."' AND
> password='".$password."'";
> $result = mysql_query($query,$conn);
> if (mysql_num_rows($result) != 0) { file://*this is the line that returns
the
> error*
> return true;
> } else {
> return false;
> }
> }
>
> I've checked that the connection works, and that the query is what it
should
> be, and the query works when I type it into the terminal. Any ideas?
>
> Thanks,
> Brian Rue
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>