Hi,

On Jun 27, 2005, at 8:24 AM, Mike Brandonisio wrote:

> Hi Pete,
>
> On Jun 27, 2005, at 3:52 AM, Pete wrote:
>
>
>> In message <[EMAIL PROTECTED]>, Mike
>> Brandonisio <[EMAIL PROTECTED]> writes
>>
>>
>>> Hi,
>>>
>>> I'm having a syntax problem when trying to use the wild card '%' in
>>> my query. Here is my code
>>>
>>> $query = 'SELECT *
>>>         FROM `memberDirectory`
>>>         WHERE `business_name` LIKE ''%'.$_POST
>>> ['business_name'].'%'' OR
>>>         `address` LIKE ''%'.$_POST['address'].'%'' OR
>>>         `suite` LIKE ''%'.$_POST['suite'].'%'' OR
>>>         `city` LIKE ''%'.$_POST['city'].'%'' OR
>>>         `cat1` LIKE ''%'.$_POST['category'].'%'' OR
>>>         `cat2` LIKE ''%'.$_POST['category'].'%'' OR
>>>         `cat3` LIKE ''%'.$_POST['category'].'%''
>>>         ORDER BY `business_name`';
>>>
>>> I do not show it here but I do a 'htmlspecialchars(trim()) on the
>>> $_POST vars earlier in the script. However the error I'm getting is
>>> on the line with that starts 'WHERE' and the error reads:
>>>
>>> Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /
>>> home/paloscha/public_html/result.php on line 29
>>>
>>> Can someone maybe point me in a direction.
>>>
>>>
>>
>> echo $query
>> before executing the query.
>>
>> Bet it's obvious!  (It isn't obvious from the above)
>>
>> And I hope that your visitors have plenty of time to wait, because
>> that
>> query looks as though it will take ages to run.
>>
>> -- 
>> Pete Clark
>>
>> http://www.hotcosta.com
>> http://www.spanishholidaybookings.com
>>
>>
>
> I'll do that. Did I make typical newbie error in formulating my
> query? If so where ... why would it take ages to run? There are only
> 5 search field on the form page that POST's to this result page. This
> is a test query the query that runs will be conditional based on each
> field that submits data. It will  not be a catch all query like
> posted here.
>
> Mike
> -- 
> Mike Brandonisio                 *    IT Planning & Support
> Tech One Illustration            *    Database Applications
> tel (630) 759-9283               *    e-Commerce
> [EMAIL PROTECTED]  *    www.techoneillustration.com
>
>

I figured it out. It should have looked like this:

$query = 'SELECT *
         FROM `memberDirectory`
         WHERE `business_name` LIKE "%'.$_POST['business_name'].'%" OR
         `address` LIKE "%'.$_POST['address'].'%" OR
         `suite` LIKE "%'.$_POST['suite'].'%" OR
         `city` LIKE "%'.$_POST['city'].'%" OR
         `cat1` LIKE "%'.$_POST['category'].'%" OR
         `cat2` LIKE "%'.$_POST['category'].'%" OR
         `cat3` LIKE "%'.$_POST['category'].'%"
         ORDER BY `business_name`';

Note the double quote, wild card, single quote and dot combo.

Thanks,
Mike
-- 
Mike Brandonisio                 *    IT Planning & Support
Tech One Illustration            *    Database Applications
tel (630) 759-9283               *    e-Commerce
[EMAIL PROTECTED]  *    www.techoneillustration.com



The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to