Thanks... mysql_error() said "No database selected". Oops... forgot to
define $db_name as a global.
----- Original Message -----
From: "Girish Nath" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Brian Rue" <[EMAIL PROTECTED]>
Sent: Sunday, December 16, 2001 8:17 PM
Subject: Re: [PHP] mysql_query() problem


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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to