rh-penguin Posted April 7, 2007 Share Posted April 7, 2007 hi, I've got the session_start(); function inserted on the second line in my index.php but when i try and view the page via browser i get this error Parse error: syntax error, unexpected T_STRING in /var/www/index.php on line 2 . It's definetlly the session_start() function thats causing this because if i remove it the page loads fine. Can anyone tell me what could be wrong? Thanks Link to comment https://forums.phpfreaks.com/topic/46072-solved-session_start-trouble/ Share on other sites More sharing options...
ballhogjoni Posted April 7, 2007 Share Posted April 7, 2007 whats before line 2? Link to comment https://forums.phpfreaks.com/topic/46072-solved-session_start-trouble/#findComment-223843 Share on other sites More sharing options...
Dragen Posted April 7, 2007 Share Posted April 7, 2007 could you show us what's at line 2? and preferably a couple of lines above and below it. Link to comment https://forums.phpfreaks.com/topic/46072-solved-session_start-trouble/#findComment-223844 Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 can you show the first 5 lines of code.. Link to comment https://forums.phpfreaks.com/topic/46072-solved-session_start-trouble/#findComment-223852 Share on other sites More sharing options...
rh-penguin Posted April 8, 2007 Author Share Posted April 8, 2007 This is the whole thing <?php session start(); if ((isset($_SESSION['user_logged']) && $_SESSION['user_logged'] != "") || (isset($_SESSION['user_password']) && $_SESSION['user_password'] != "")) { include "logged_user.php"; } else { include "unlogged_user.php"; } ?> Link to comment https://forums.phpfreaks.com/topic/46072-solved-session_start-trouble/#findComment-223861 Share on other sites More sharing options...
MadTechie Posted April 8, 2007 Share Posted April 8, 2007 change to <?php session_start(); if ( (isset($_SESSION['user_logged']) && ($_SESSION['user_logged'] != "") || ( isset($_SESSION['user_password'])) && ($_SESSION['user_password'] != "") ) { include "logged_user.php"; } else { include "unlogged_user.php"; } ?> Note the _ on session_start(); & the if statment was incorrect Link to comment https://forums.phpfreaks.com/topic/46072-solved-session_start-trouble/#findComment-223869 Share on other sites More sharing options...
rh-penguin Posted April 8, 2007 Author Share Posted April 8, 2007 dont seem to make any difference Link to comment https://forums.phpfreaks.com/topic/46072-solved-session_start-trouble/#findComment-223871 Share on other sites More sharing options...
MadTechie Posted April 8, 2007 Share Posted April 8, 2007 i just tested this <?php session_start(); if ( ( isset($_SESSION['user_logged']) && $_SESSION['user_logged'] != "") || ( isset($_SESSION['user_password']) && $_SESSION['user_password'] != "") ) { //include "logged_user.php"; echo "logged_user.php"; } else { //include "unlogged_user.php"; echo "unlogged_user.php"; } die; ?> result unlogged_user.php no errors please post your revised code Link to comment https://forums.phpfreaks.com/topic/46072-solved-session_start-trouble/#findComment-223872 Share on other sites More sharing options...
rh-penguin Posted April 8, 2007 Author Share Posted April 8, 2007 yea it works now........... Thats strage, why does it seem to matter how i'm placing my code? Link to comment https://forums.phpfreaks.com/topic/46072-solved-session_start-trouble/#findComment-223880 Share on other sites More sharing options...
MadTechie Posted April 8, 2007 Share Posted April 8, 2007 session_start(); works like a header as for the rest you did miss the _ and a ) on the if if you see how i broke up the if statement.. i did that to make it easier to read (well for me ) Link to comment https://forums.phpfreaks.com/topic/46072-solved-session_start-trouble/#findComment-223881 Share on other sites More sharing options...
rh-penguin Posted April 8, 2007 Author Share Posted April 8, 2007 clumsyness................. Thanks for the help all! Happy easter! Link to comment https://forums.phpfreaks.com/topic/46072-solved-session_start-trouble/#findComment-223886 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.