Page 1 of 1

unexpected $end

Posted: Fri Aug 11, 2006 11:09 pm
by SidewinderX
ok well i have a bunch of files that i dont want users to be able to access unless the install files are deleted. each file is formated like so:

Code: Select all

<?php
include("header.php");
include("config.php");
//code
//more code
//even MORE code
include("footer.php");
?>
I created a simple script to test to see if the install directory exists:

Code: Select all

<?php
$dir = "install/";
if (is_dir($dir)) {
echo "THE INSTALL DIRECTORY EXISTS, YOU MUST REMOVE IT BEFORE YOU CONTINUE.";
}
else{
echo "THE INSTALL DIRECTORY DOES NOT EXIST";
}
?>
And rather than adding that code to each file, i had planned to add the code to the header and footer. For example header.php would include

Code: Select all

<?php
$dir = "install/";
if (is_dir($dir)) {
echo "THE INSTALL DIRECTORY EXISTS, YOU MUST REMOVE IT BEFORE YOU CONTINUE.";
}
else{
?>
and footer.php would have

Code: Select all

<?php
}
?>
i thought this would work but i get an error
Parse error: syntax error, unexpected $end in c:\www\toplist\header.php on line 7
i assume its because of the open else {

is that infact the reason? if so, is there any easy way of doing what i want rather than adding that code to each file?

Posted: Fri Aug 11, 2006 11:35 pm
by feyd
yes, it is the fault of the open else.

viewtopic.php?t=53407 is the solution.

Posted: Sat Aug 12, 2006 1:16 pm
by TJH
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,

     You should write this code in only one file. It shoud be in header.php.

Code: Select all

<?php 
$dir = "install/"; 
if (is_dir($dir)) { 
echo "THE INSTALL DIRECTORY EXISTS, YOU MUST REMOVE IT BEFORE YOU CONTINUE."; 
exit;
} 


 Cheers..  

?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]