You are here: Re: HELP: pesky SQL syntax error using PHP variables « PHP Programming Language « IT news, forums, messages
Re: HELP: pesky SQL syntax error using PHP variables

Posted by David Haynes on 12/17/64 11:52

Frankie wrote:
> Hello:
>
> New user here...first post to group.
>
> I'm getting an SQL syntax error when I try to run the following query:
>
> $query = sprintf("SELECT itemNumber, entryDate, modifyDate, thumbnailURL,
> title, price FROM '%s' WHERE itemNumber = '%s'", $_POST['selectCategory'],
> $_POST['tfItemNum']);
>
> I've tested the variables and they are populated.
>
> Strangely, the query works with a variable in the WHERE clause, but not in
> the FROM clause.
>
> Any tips appreciated,
>
> Frank H
> Austin, TX
>
>

Your FROM clause would be FROM 'foo'. It should be FROM foo instead.

Try:
$query = sprintf("SELECT itemNumber, entryDate, modifyDate,
thumbnailURL, title, price FROM %s WHERE itemNumber = '%s'",
$_POST['selectCategory'], $_POST['tfItemNum']);

-david-

 

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

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