Reply to Re: correct syntax?

Your name:

Reply:


Posted by aggelos on 06/17/05 12:07

Veikko Mäkinen wrote:
what about :
$thecustid = "SELECT custid FROM customers WHERE userid ='"
$_SESSION['MM_Username']."'";

> Tom Thackrey wrote:
>> On 16-Jun-2005, "Kimmo Laine" <eternal.erectionN0.5P@Mgmail.com> wrote:
>>
>>
>>>>$thecustid = 'SELECT custid FROM customers WHERE userid =
>>>>$_SESSION['MM_Username']';
>>>
>>>
>>>Using single qoutes in this case is wrong because a) you've got single
>>>qoutes inside single qoutes, and that my freind, makes php go apeshit. b)
>>>it
>>>doesn't interpret variables inside a string if the string is delimited by
>>>single qoutes.
>>>
>>>Throw in some double qoutes:
>>>$thecustid = "SELECT custid FROM customers WHERE userid =
>>> $_SESSION['MM_Username']";
>>>
>>>And that should work.
>>
>>
>> Actually you need to remove the single quotes from around MM_Username (or
>> add {} braces around the whole variable), too. If userid is not numeric,
>> you need to add single quotes around its value to make the SQL correct,
>> so you get:
>>
>> $thecustid = "SELECT custid FROM customers WHERE userid =
>> '$_SESSION[MM_Username]' ";
>
> You shouldn't mix string keys and constanst. So instead of
>
> " $_SESSION[MM_Username] "
> (looks for a constant named "MM_Username" and if it doesn't find it,
> uses 'MM_Username' as a string key)
>
> use
>
> " {$_SESSION['MM_Username']} " as suggested in the manual.
>
>>
http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing
>
>
> -veikko
>

--
Love Peace and Linux

[Back to original 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

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