Jump to content

[SOLVED] session_start(); trouble


rh-penguin

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.