You are here: Re: HELP: PHP search query SQL error « PHP Programming Language « IT news, forums, messages
Re: HELP: PHP search query SQL error

Posted by Bob Smith on 07/28/06 19:19

On 7/28/2006 2:51 PM, Frankie wrote:
> I'm trying to run the following search query:
>
> $query =
> sprintf ("SELECT itemNumber, thumbnailURL, title, description, price
> FROM apparel,hats
> WHERE apparel.title OR apparel.description OR hats.title OR
> hats.description
> LIKE '%s'",
> $_POST['tfSearch']);
>
> but it returns this error:
>
> "Column: 'itemNumber' in field list is ambiguous"
>
> Both "apparel" and "hats" tables share the same columns specified in the
> SELECT clause.
>
> What I'm I missing?

Indeed it is ambiguous. To avoid this, use apparel.itemNumber or
hats.itemNumber in the SELECT list. Repeat for the other columns.

Also, to avoid an SQL injection attack, be sure to filter the input in
$_POST[...] using a function appropriate to your SQL implementation.

--
_________________________________________
Bob Smith -- bsmith@sudleydeplacespam.com

To reply to me directly, delete "despam".

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация