Jump to content

Recommended Posts

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

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";
}

?>

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

 

 

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

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.