Re: mysql_query and SELECT syntax (Using php4, mysql, apache on WIndows XP home)

From: Date: Wed, 07 Aug 2002 15:03:04 +0000
Subject: Re: mysql_query and SELECT syntax (Using php4, mysql, apache on WIndows XP home)
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-15154@lists.php.net to get a copy of this message
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

« previous php.windows (#15154) next »