Question:
Need Help with php, Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'?
LIAM
2012-03-26 03:51:24 UTC
hi im new to php and im doing a very basic login system,

when i view my work im gettin this error when the user has logged in and clicked on the members page.

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\member.php on line 9

my member.php is


session_start();

if (isset($_SESSION['username']))

echo "Welcome, ".$_SESSION['username'] ."!
logout,;
else
die"you must be logged in!";
?>



i know its basic but im very new to this and any help would be appriciated.

thanks, liam
Three answers:
2012-03-26 03:57:02 UTC
You need double quotes " between the tag and the ; otherwise it will see everything until the double quotes after die as part of the string



die is a function, so you need to put its agrument in brackets.



So it should read



die("you must be logged in!");
2012-03-26 11:10:53 UTC
echo "Welcome, ".$_SESSION['username'] ."!
logout,";



need a double quotes at the end of line...just before semicolon



You should put the die function in bracket with double inverted comma.



That will make your programs run



and don't leave any line blank line after the IF condition, as you're not using 2nd bracket "{ }" which is always recommended, so you need to make sure that you won't leave any blank line out there.



Otherwise it may give you an error.



Thanks!!!!!!!!!
Punitha J
2012-03-26 12:00:33 UTC
You need double quotes " between the tag and the ; otherwise it will see everything until the double quotes after die as part of the string



die is a function, so you need to put its agrument in brackets.



So it should read



die("you must be logged in!");


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...