RE: [PHP-WIN] mysql_query and SELECT syntax (Using php4, mysql, a pache on WIndows XP home)
| From: | dash php | Date: | Wed, 07 Aug 2002 16:44:10 +0000 |
| Subject: | RE: [PHP-WIN] mysql_query and SELECT syntax (Using php4, mysql, a pache on WIndows XP home) | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-15157@lists.php.net to get a copy of this message | ||
Don't you have to do the following:
$query = "SELECT username FROM $user_tablename WHERE userid = "$userid' AND
WHERE userpassword = password('$userpassword')";
??? (replaced the AND with AND WHERE)
Disclaimer: I'm a bit new to MySQL myself but my legacy database at work
requires one to do that.
-Dash (.php)
-----Original Message-----
From: DL Neil [mailto:PHPml@DandE.HomeChoice.co.uk]
Sent: Wednesday, August 07, 2002 8:03 AM
To: Marlene Burckhalter; php-windows@lists.php.net
Subject: Re: [PHP-WIN] mysql_query and SELECT syntax (Using php4, mysql,
apache on WIndows XP home)
Marlene,
I want to SELECT a field from a table but only if it meets TWO criteria and
then assign it to $result. I can get this code (only requiring one
criteria) to work:
After connecting to my database...
Partial code in a function:
$query = "SELECT username FROM $user_tablename
WHERE userid = '$userid'";
$result = mysql_query($query);
if (!mysql_num_rows($result)) return 0;
else {
$query_data = mysql_fetch_row($result);
return $query_data[0];
}
But when I try to add another crtiteria...
WHERE userid = "$userid'
AND userpassword =
password('$userpassword')";
I get an error about mysql_num_rows() supplied argument is not a valid MySQL
result resource. Can anyone help?
=If the final query is:
$query = "SELECT username FROM $user_tablename
WHERE userid = "$userid'
AND userpassword =
password('$userpassword')";
then the quotation marks don't balance correctly.
Standard advice: print the SQL before calling the RDBMS so that you can see
what is actually transferred.
=dn
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php