Re: Query Syntax - WHERE fieldname1='fieldvalue1' AND fieldname2='fieldvalue2'

From: Date: Tue, 22 May 2007 16:35:06 +0000
Subject: Re: Query Syntax - WHERE fieldname1='fieldvalue1' AND fieldname2='fieldvalue2'
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-27936@lists.php.net to get a copy of this message
Mark Abrams wrote:
#2 FAILS $query = "SELECT $field_name FROM classifieds WHERE $field_name1 = '$field_value1' AND $field_name2 ='$field_value2'"; $result = mysql_query($query) or die(mysql_error()); dies with the following message: Warning: mysql_query() [http://www.mysql.com/doc]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM classifieds WHERE trans_type = 'For Sale' AND category ='Boats'' at line 1 in C:\apache2triad\htdocs\
Have you tried printing out $query to see exactly what you're sending? Seems like a logical first step to me. Something about it is clearly wrong, and I'm guess it's an empty or wrong $field_name value. -Stut

« previous php.windows (#27936) next »