RESOLVED - Thank you Stut - Re: [PHP-WIN] WHERE fieldname1='fieldvalue1' AND fieldname2='fieldvalue2'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you Stut.  I feel like a fool.  Little gremlins removed the SELECT 
column.

Everyone - I appreciate your support.  Its easy to get a blind spot and I 
have had one all morning.
Regards,
Mark


"Stut" <stuttle@xxxxxxxxx> wrote in message 
news:46532FAF.7000803@xxxxxxxxxxxx
> Mark Abrams wrote:
>> Here are the query strings &  printouts:
>>
>> This works OK
>>      $query = "SELECT $field_name FROM classifieds WHERE $field_name1 = 
>> '$field_value1' AND $field_name2 = '$field_value2'";
>>
>>     SELECT FROM classifieds WHERE trans_type ="For Sale"
>>
>> FAILS
>
> Of course it does. You want to select *WHAT* from classifieds? As I 
> suspected. $field_name is empty or not defined.
>
>> #1
>>     $query = "SELECT $field_name FROM classifieds WHERE $field_name1 = 
>> '$field_value1' AND $field_name2 = '$field_value2'";
>>
>>     SELECT FROM classifieds WHERE trans_type = 'For Sale' AND category = 
>> 'Books'
>>
>> 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 trans_type = 'For Sale'' at line 1 in 
>> C:\apache2triad\htdocs\sunlakes\test3.php on line 82
>
> Ditto.
>
>> #2
>>       $query = "SELECT $field_name
>>               FROM classifieds
>>               WHERE ($field_name1 = '".$field_value1."')
>>               AND   ($field_name2 = '".$field_value2."')";
>>
>>      SELECT FROM classifieds WHERE (trans_type = 'For Sale') AND 
>> (category = 'Books')
>>
>>
>> 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 (tr' at line 2 in 
>> C:\apache2triad\htdocs\sunlakes\test3.php on line 85
>
> Ditto.
>
> -Stut
>
>> "Stut" <stuttle@xxxxxxxxx> wrote in message 
>> news:46531BBA.5010207@xxxxxxxxxxxx
>>> 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
>> 

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux