Parse error: parse error, unexpected T_VAR in C:\Documents and Settings\Neil\My Documents\www\template atm\membership.php on line 23
| SitePoint Sponsor |
Parse error: parse error, unexpected T_VAR in C:\Documents and Settings\Neil\My Documents\www\template atm\membership.php on line 23
post ur lines of code here let us know line no. 23 as well
Hey,
Site Code:
Please note that the session start code is above the code i have posted.PHP Code:<?php
//Define loggedin
var $_SESSION['loggedin'];
//Define action
var $_GET['action'];
//$_SESSION['loggedin'] = 1;
if ($_GET['action'] == "")
{
if ($_SESSION['loggedin'] == 0)
{
echo "Default Page";
}
else
{
echo "Normal Page when Logged In";
}
}
if ($_GET['action'] == "login" )
{
if ($_SESSION['loggedin'] == 1)
{
echo "Already Logged In Message";
}
else
{
echo "Log in Form"
}
}
if ($_GET['action'] == "register" )
{
if ($_SESSION['loggedin'] == 1)
{
echo "Already logged in and registered message";
}
else
{
echo "Registration Form";
}
}
?>
<!--New Lines-->
<br /><br />
<!--End New Lines-->
Line 23 is this line:
ThanksPHP Code:var $_SESSION['loggedin'];
Neil
PHP Code:<?php
error_reporting(0);
if ($_GET['action'] == "")
{
if ($_SESSION['loggedin'] == 0)
{
echo "Default Page";
}
else
{
echo "Normal Page when Logged In";
}
}
if ($_GET['action'] == "login" )
{
if ($_SESSION['loggedin'] == 1)
{
echo "Already Logged In Message";
}
else
{
echo "Log in Form"
}
}
if ($_GET['action'] == "register" )
{
if ($_SESSION['loggedin'] == 1)
{
echo "Already logged in and registered message";
}
else
{
echo "Registration Form";
}
}
?>
try debuging ur self else this problem dont have any end, am not able to see ur complete code
That is my complete code, I basically have a php function above and below the code i posted which calls in the start html, with head and start body tag, layout and all that and the below function closes the layout div and ends the body and html stuff. - So why can't it be debugged as it is.
whts the o/p of above code
output of my code which i posted just above
wht kind of output u r getting after using following code :
b4 this ve u ever work vth PHP ?PHP Code:<?php
error_reporting(0);
if ($_GET['action'] == "")
{
if ($_SESSION['loggedin'] == 0)
{
echo "Default Page";
}
else
{
echo "Normal Page when Logged In";
}
}
if ($_GET['action'] == "login" )
{
if ($_SESSION['loggedin'] == 1)
{
echo "Already Logged In Message";
}
else
{
echo "Log in Form"
}
}
if ($_GET['action'] == "register" )
{
if ($_SESSION['loggedin'] == 1)
{
echo "Already logged in and registered message";
}
else
{
echo "Registration Form";
}
}
?>
When using the code you posted i get an unexpected } error on line 45
Line 45 is the middle line of:
{
echo "Log in Form"
}
}
Thanks
Neil
oh come on u can solve that by urself give a try b4 post here
put a ; after echo and try again..........
whenever u use session variable u need to start the session first am assuming that u r starting session on this file only or on some other file and including that file here or vice versa......................
Last edited by simplecode; Jan 10, 2007 at 17:12.
is that working ?
I'll post the results tommorow and yes the session is beung started on anther page. which is being included
2morow y not now
Hey,
Using that latest code, I view the page and it says Default Page. I'll just set the session to 1 and see what happens!
Hey, An Update!
If i use
$_SESSION['loggedin'] = 1;
then the page shows "Normal Page when logged in" which is great - just as it was meat to do.
I then commented out the error reporting line (As i DO want error reporting ON) and it still worked great!
I will now add in the content i need in each area and will post here if anything else develops!
Thanks
Neil
what happ??????
What happened with what?
nothing......
its gr8 2 hear that finally its working.....![]()
Everything is working fine so far. Can you just let me know if this code is written right as "You are not logged in" seems to be showing all the time!
ThanksPHP Code:if ($_GET['action'] == "logout" ){
if ($_SESSION['loggedin'] == 1)
{
unset($_SESSION['username']);
unset($_SESSION['id']);
unset($_SESSION['loggedin']);
echo 'Thanks for logging out. <a href="membership.php">Click here to go back to the membership system.</a>';
}
} else {
echo 'You are not logged in';
}
Neil
if ($_GET['action'] == "logout" )
if theis condition is true then echo 'You are not logged in'; will not get displayed but if if ($_GET['action'] != "logout" ) then it will come to else part
if u want to show that message when user is not logged in do like this
http://www.w3schools.com/php/php_if_else.aspPHP Code:if ($_GET['action'] == "logout" )
{
if ($_SESSION['loggedin'] == 1)
{
unset($_SESSION['username']);
unset($_SESSION['id']);
unset($_SESSION['loggedin']);
echo 'Thanks for logging out. <a href="membership.php">Click here to go back to the membership system.</a>';
}
//assuming that action == logout means user is loggedout
echo 'You are not logged in';
}
try to learn from all post
Bookmarks