bkribbs Posted December 25, 2011 Share Posted December 25, 2011 Hey, I am new to PHP. I am experimenting with cookies, and am having some trouble with the syntax for part of it. I am checking if that cookie exists, and if it is there, I want it to say, you are logged in as "(cookie has username stored)" <?php if( isset( $_COOKIE['username'] ) ) { echo 'You are logged in as', var_dump($_COOKIE ); } else { echo 'you aren't logged in!'; } ?> I'm sure this is simple, but I don't know. Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/253824-help-with-error/ Share on other sites More sharing options...
Pikachu2000 Posted December 25, 2011 Share Posted December 25, 2011 So what seems to be the problem? Quote Link to comment https://forums.phpfreaks.com/topic/253824-help-with-error/#findComment-1301275 Share on other sites More sharing options...
bkribbs Posted December 25, 2011 Author Share Posted December 25, 2011 It returns this error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\Documents and Settings\bkribbs\Desktop\Site\amiinpage.php on line 21 Quote Link to comment https://forums.phpfreaks.com/topic/253824-help-with-error/#findComment-1301277 Share on other sites More sharing options...
Pikachu2000 Posted December 25, 2011 Share Posted December 25, 2011 When using the same type of quote within a string as the quotes that enclose the string, you must escape the enclosed quotes. See the manual regarding string data, and how to escape quotes, etc. http://www.php.net/manual/en/language.types.string.php echo 'you aren't logged in!'; Quote Link to comment https://forums.phpfreaks.com/topic/253824-help-with-error/#findComment-1301279 Share on other sites More sharing options...
bkribbs Posted December 25, 2011 Author Share Posted December 25, 2011 Well thanks! That was rather stupid of me. Quote Link to comment https://forums.phpfreaks.com/topic/253824-help-with-error/#findComment-1301284 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.