You are here: Re: Help with variable interpolation in WHER clause « PHP Programming Language « IT news, forums, messages
Re: Help with variable interpolation in WHER clause

Posted by Jerry Stuckle on 05/18/06 22:01

Alan Little wrote:
> Carved in mystic runes upon the very living rock, the last words of
> Sjoerd of comp.lang.php make plain:
>
>
>>>//$query = 'SELECT TITLE, NAME, INST, ADD1, ADDR2, ADDR3, PH, FAX,
>>>EMAIL FROM officers WHERE GRP = $w';
>>
>>When a string is between 'single quotes', variables are not parsed.
>>This means that after
>>$query = 'SELECT $w'
>>The variable query literaly contains SELECT $w. To use the value of
>>the variable w instead, use double quotes:
>>$query = "SELECT $w"
>>This becomes SELECT and then the value of variable w.
>>
>>Another option is to use the concatination operator, which is a dot.
>>$query = 'SELECT '.$w
>>This way, the string 'SELECT ' and the variable w are concatenated
>>together.
>
>
> And don't forget to enclose the value in single quotes within the query:
>
> "...WHERE GRP = '$w'";
>

Only if it's non-numeric.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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