View Full Version : Unexpected T_CONSTANT_ENCAPSED_STRING in /home... on line 1


liam1412
12-06-2008, 08:24
Just a quick one coz this is driving me mad. As far as im aware nothing has changed in the script and it suddenly started throwing this error. Can anyone spot anything??


<?php

session_start();

if(!isset($_SESSION['userid']) || ($_SESSION['userlevel'] != 3))

{

header("location:unauthorised.php");

exit();

}

include 'header.php';

?>

<div class="content">

<div class="contentheader">

<div class="contentheaderpad">

<h2>Admin Area</h2>

</div>

</div>

<div class="contentpad">

Welcome to the admin area. From here you can manage users, forums, add listings and manage every part of the site. Any activity from within this

page is monitored and any abuse will result in the IP address been blocked from access to the site in anyway.

</div>

</div>

<div class="content">

<div class="contentheader">

<div class="contentheaderpad">

<h2>Hosting Provider Admin</h2>

</div>

</div>

<div class="contentpad">

<center>

<?php

include 'mysql.php';

$getCurrentHosts = mysql_query("SELECT * FROM hostingproviders ORDER BY hostingproviderid");

$numHosts = mysql_num_rows($getCurrentHosts);

if($numHosts > 1)

{

while($fetchCurrentHosts = mysql_fetch_array($getCurrentHosts))

{

$providername = $fetchCurrentHosts['providername'];

$bannerCode = stripslashes($fetchCurrentHosts['bannercode']);

echo $bannerCode;

?>

<br />

<a href="edithostdets.php">Edit This entry</a> | <a href="admin.php?deletehost=1">Delete This Listing</a>

<br />

<?php

}

}

else

{

echo '<br />We currently have no hosts listed at this time<br /><br /><br />';

}

mysql_close();

?>

</center>

</div>

</div>

<?php

include 'footer.php';

?>

Sheff_Tutor
12-06-2008, 15:14
I just tested this by commeting out

//header("location:unauthorised.php");
//exit();
//include 'header.php';
and it seems fine (except telling me of where things dont exist or sql querry isnt working

Try doing this to, if it works for you, then you know the error lies there

Ghozer
12-06-2008, 15:31
yeah, he's missing a () on his if..

if(!isset($_SESSION['userid']) || ($_SESSION['userlevel'] != 3))

should be

if((!isset($_SESSION['userid'])) || ($_SESSION['userlevel'] != 3))

to avoid such issues..

Sheff_Tutor
12-06-2008, 15:56
yeah, he's missing a () on his if..

if(!isset($_SESSION['userid']) || ($_SESSION['userlevel'] != 3))

should be

if((!isset($_SESSION['userid'])) || ($_SESSION['userlevel'] != 3))

to avoid such issues..
Oh yes, that a pretty good point, I wonder why commenting out what I did still worked though?

if (false) || (false)) {
// bla
}
should still throw an error shouldnt it?

liam1412
12-06-2008, 16:26
Well. I gave up in the end and re-wrote it and it works. It was strange how it was working and then it suddenly stopped. And as I commented bits out it even said at one point

call to undefined function session_start() :loopy:

So I scrapped it and re wrote.

I think core ftp is sometimes doing crazy things with the file, maybe changing the charset, or filetype. I dunno.

Anyone else had problems with coreftp.

dosxuk
12-06-2008, 16:28
That's not what he had though, he had
if (false || (false))

What is the full error message Liam? It's truncated here... are you sure the error is in this file as it says the problem is on line 1 and that's fine in what you've posted here.

John
12-06-2008, 16:28
yeah, he's missing a () on his if..

if(!isset($_SESSION['userid']) || ($_SESSION['userlevel'] != 3))

should be

if((!isset($_SESSION['userid'])) || ($_SESSION['userlevel'] != 3))

to avoid such issues..

What issue?

There was nothing wrong with the if statement.

Ghozer
12-06-2008, 17:11
when it says there's a problem, its always the line after, so if it stated "on line 1" that was the last successful execution of script before it hit an error, a missing ; or parenthesis or something.

Ghozer
12-06-2008, 17:12
What issue?

There was nothing wrong with the if statement.

I have had problems with.

if (!false(something) || (this = that)) {

before, and have always ended up doing it as

if ((!false(something)) || (this = that)) {

which has always solved the problem... I agree it looks ok and should work in the first instance, and most of the time it does, but for some odd reason it some times doesnt.

Sheff_Tutor
12-06-2008, 17:20
It must be the editor, I've never had problems with core ftp, but I know my editor some times truncates the code and misses of the ?> at the very bottom (crimson editor) . The code its self seemed to work fine when I coppied from here though

liam1412
13-06-2008, 16:13
I only use notepad2.

Hey ho. its sorted now anyway. And my if statements are still the same so im not gonna change em unless I get any problems.