RE: [PHP-WIN] mysql_query and SELECT syntax (Using php4, mysql, apache on WIndows XP home)

From: Date: Wed, 07 Aug 2002 14:24:45 +0000
Subject: RE: [PHP-WIN] 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-15153@lists.php.net to get a copy of this message
Marlene I would guess you introduce a syntax error with your second criteria which causes the query to fail - it seems at first glance that you hve an unmatched single quote after the $userid Try echo mysql_error(); directly after the query is executed... Rich -----Original Message----- From: Marlene Burckhalter [mailto:mburckhalter@triad.rr.com] Sent: 07 August 2002 15:03 To: php-windows@lists.php.net Subject: [PHP-WIN] mysql_query and SELECT syntax (Using php4, mysql, apache on WIndows XP home) 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?

« previous php.windows (#15153) next »