If used outside any strings (like in your $query example)
$_SESSION[foo]  --  here foo technically is a constant
                and php ought to produce a notice
$_SESSION['foo']  --  is the correct way as there is no doubt that foo
                  is a string

When used inside a string the rules are slightly altered
@see http://www.php.net/manual/en/language.types.array.php
section Array do's and don'ts

Richard


Friday, April 16, 2004, 6:32:11 PM, you wrote:

> Whats the difference between $_SESSION[foo] and $_SESSION['foo'] I have been
> using the 's but they seem to be unecessary?

> I run into trouble if I try something like:


> $query = " select * from table where (test.id = '$_SESSION['foo']') ";

> but the following works:

> $query = " select * from table where (test.id = '$_SESSION[foo]') ";


> I know there is some way to properly escape characters but is there any
> reason why I shouldn't just omit the 's?


> Thanks!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to