crouzilles Posted April 27, 2008 Share Posted April 27, 2008 Hello all, I am new to PHP and to your community. I have a little programming experience in Tcl, DHTML. This is the problem I am encountering: echo("cookie is now set to: $_COOKIE['GSAdminUser']"); The line above comes back with this errror: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/username/gs_admin/test.php on line 18 If I assign the value of $_COOKIE['GSAdminUser'] to a variable and then use this variable in the echo command, all is fine and I cann see the cookie value in the page. Does anybody know what I can't use the $_COOKIE['GSAdminUser'] variable directly? Thank you Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 27, 2008 Share Posted April 27, 2008 should be echo("cookie is now set to: {$_COOKIE['GSAdminUser']}"); If you want to access arrays inside of a string you need to use the 'curly bracket' sytax. http://www.phpcodinghelp.com/article.php?article=strings#syntax_variable Quote Link to comment Share on other sites More sharing options...
crouzilles Posted April 27, 2008 Author Share Posted April 27, 2008 Unfortunately, it still does not work. This is my file: <?php setcookie("GSAdminUser", "xbourgui:1", time()+3600, "/", "127.0.0.1", 0); ?> <html> <head> <link rel="styleSheet" href="css/main.css" type="text/css"> </head> <body class="main"> <?php if (isset($_COOKIE['GSAdminUSer'])) { echo('no cookie available'); } else { echo("cookie is now set to: {$_COOKIE['GSAdminUSer']}"); } ?> </body> </html> All I get on screen now is this: cookie is now set to: Any ideas? Thank you Quote Link to comment Share on other sites More sharing options...
crouzilles Posted April 27, 2008 Author Share Posted April 27, 2008 Actually guys, Forgive me about this. I have found the problem. I call my cookie GSAdminUser, but I refer to it as GSAdminUSer. Note the uppercase 'S'? Sorry again, my mistake. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.