Jump to content

[SOLVED] using variables in strings


crouzilles

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.