Re: [PHP] echo and Session Variables
On Thursday, March 21, 2002, at 06:26 PM, David Johansen wrote: > Thanks that fixed the problem, but I have a question then. Am I > supposed to > put the ' in the $_SESSION[] in the normal parts of code. Thanks, > Dave You should use either single quotes or double quotes in any associative index. You do not need to use them for numeric indices. $_SESSION['x_Email'] $_POST['loginName'] $form_html['button'] $count[1] $item[7] Don't forget that variables will not expand within single quotes. Use double quotes if you have a variable in your associative index. $_POST["filename{$i}"] Again, not really an issue for numeric indices. $input[$c] Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] echo and Session Variables
Please note that an unquoted array key is now deprecated syntax. See http://www.php.net/manual/en/language.types.array.php Kirk > The single quotes in $_SESSION['myvar'] are not necessary. You're > reading an associative array in which a string is acting as a > pointer to > the index. > > Example.. > $myarray = array ('myvar' => 'myvalue'); > echo $myarray[myvar]; // prints out 'myvalue' > -Kevin > > -Original Message- > From: David Johansen [mailto:[EMAIL PROTECTED]] > Sent: Thursday, March 21, 2002 4:26 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] echo and Session Variables > > Thanks that fixed the problem, but I have a question then. Am > I supposed > to > put the ' in the $_SESSION[] in the normal parts of code. Thanks, > Dave > > "Miguel Cruz" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > On Thu, 21 Mar 2002, David Johansen wrote: > > > I was just wondering if there's a way to use echo with session > variables. > > > When I try to do this: > > > > > > > > if (isset($_SESSION['x_Email'])) > > > echo "value=\"$_SESSION['x_Email']\""; > > > ?> > > > > The issue is with the syntax you're using to refer to arrays within > double > > quotes. > > > >echo "value=\"{$_SESSION[x_Email]}\""; > > > > miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] echo and Session Variables
Well, a stray define('myvar','foo') somewhere would make a mess of that. It is safer to use $myarray['myvar']. Inside a quoted string you of course shouldn't use the '' -Rasmus On Thu, 21 Mar 2002, Kevin Stone wrote: > The single quotes in $_SESSION['myvar'] are not necessary. You're > reading an associative array in which a string is acting as a pointer to > the index. > > Example.. > $myarray = array ('myvar' => 'myvalue'); > echo $myarray[myvar]; // prints out 'myvalue' > -Kevin > > -Original Message- > From: David Johansen [mailto:[EMAIL PROTECTED]] > Sent: Thursday, March 21, 2002 4:26 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] echo and Session Variables > > Thanks that fixed the problem, but I have a question then. Am I supposed > to > put the ' in the $_SESSION[] in the normal parts of code. Thanks, > Dave > > "Miguel Cruz" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > On Thu, 21 Mar 2002, David Johansen wrote: > > > I was just wondering if there's a way to use echo with session > variables. > > > When I try to do this: > > > > > > > > if (isset($_SESSION['x_Email'])) > > > echo "value=\"$_SESSION['x_Email']\""; > > > ?> > > > > The issue is with the syntax you're using to refer to arrays within > double > > quotes. > > > >echo "value=\"{$_SESSION[x_Email]}\""; > > > > miguel > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] echo and Session Variables
The single quotes in $_SESSION['myvar'] are not necessary. You're reading an associative array in which a string is acting as a pointer to the index. Example.. $myarray = array ('myvar' => 'myvalue'); echo $myarray[myvar]; // prints out 'myvalue' -Kevin -Original Message- From: David Johansen [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 21, 2002 4:26 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] echo and Session Variables Thanks that fixed the problem, but I have a question then. Am I supposed to put the ' in the $_SESSION[] in the normal parts of code. Thanks, Dave "Miguel Cruz" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > On Thu, 21 Mar 2002, David Johansen wrote: > > I was just wondering if there's a way to use echo with session variables. > > When I try to do this: > > > > > if (isset($_SESSION['x_Email'])) > > echo "value=\"$_SESSION['x_Email']\""; > > ?> > > The issue is with the syntax you're using to refer to arrays within double > quotes. > >echo "value=\"{$_SESSION[x_Email]}\""; > > miguel > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo and Session Variables
Thanks that fixed the problem, but I have a question then. Am I supposed to put the ' in the $_SESSION[] in the normal parts of code. Thanks, Dave "Miguel Cruz" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > On Thu, 21 Mar 2002, David Johansen wrote: > > I was just wondering if there's a way to use echo with session variables. > > When I try to do this: > > > > > if (isset($_SESSION['x_Email'])) > > echo "value=\"$_SESSION['x_Email']\""; > > ?> > > The issue is with the syntax you're using to refer to arrays within double > quotes. > >echo "value=\"{$_SESSION[x_Email]}\""; > > miguel > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo and Session Variables
On Thu, 21 Mar 2002, David Johansen wrote: > I was just wondering if there's a way to use echo with session variables. > When I try to do this: > > if (isset($_SESSION['x_Email'])) > echo "value=\"$_SESSION['x_Email']\""; > ?> The issue is with the syntax you're using to refer to arrays within double quotes. echo "value=\"{$_SESSION[x_Email]}\""; miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] echo and Session Variables
I was just wondering if there's a way to use echo with session variables. When I try to do this: it gives me this error: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/storings/public_html/uslogin.php on line 134 Am I doing something wrong or is there a better way to do this? I know that I could use printf() but is there a way to do it with echo and is accessing the session variables with $_SESSION[] the "right" way to do it? Thanks, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php