Schlo_50 Posted November 7, 2007 Share Posted November 7, 2007 Hi, I have a script which doesn't work t the moment and generates the following error: parse error, unexpected $end on line .. The line is the last line of code..i've made sure there is now 'white space' and now want to see if all the curly brackets are there, but after looking again and again and making my eyes hurt im just confusing myself and now have to accept i can't count.. lol Could someone just double check for me that all the brackets are matched, Thanks!! <?php require_once('operate.php'); checkUser(); ?> <link href="style.css" rel="stylesheet" type="text/css"> <?php //Filename $file_name = $HTTP_POST_FILES['ufile']['name']; //Rename $random_digit = ("excursion.pdf"); //Create new name $new_file_name=$random_digit; $max_size = "500"; $extension = pathinfo($_FILES['ufile']['name']); $extension = $extension[extension]; $allowed_paths = explode(", ", $allowed_ext); for($i = 0; $i < count($allowed_paths); $i++) { if ($allowed_paths[$i] == "$extension") { $ok = "1"; } } if ($ok == "1") { if($_FILES['ufile']['size'] > $max_size) { print "File size is too big!"; exit; } $path= "/path/".$new_file_name; if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "<span class=main><body bgcolor=#CC9933><table width=383 height=286 border=1 align=center bordercolor=#666666> <tr><td width=377 colspan=2 valign=top bgcolor=#666666><p align=center class=title><img src=img/top.png width=608 height=110 /></p> <font color=#FFFFFF size=1 face=verdana><center>Your file has been uploaded successfully! <br /><br /><a href=logout.php>Logout</a></center></font> </td></tr> </table></body><p align=center class=main>Website Designed by </p></span>"; //Display new name for testing, Delete when implementing! echo "File Name :".$new_file_name."<BR/>"; } else { echo "<span class=main><body bgcolor=#CC9933><table width=383 height=286 border=1 align=center bordercolor=#666666> <tr><td width=377 colspan=2 valign=top bgcolor=#666666><p align=center class=title><img src=img/top.png width=608 height=110 /></p> <font color=#FFFFFF size=1 face=verdana><p><center>Incorrect file extension!<br /><br /><a href=action.php>Try Again</a><br /><a href=logout.php>Logout</a></center></p></font> </td></tr> </table></body><p align=center class=main></p></span>"; } ?> Thanks all! Quote Link to comment Share on other sites More sharing options...
aschk Posted November 7, 2007 Share Posted November 7, 2007 You might to try indenting your code once in a while so that you can see your bracket matches... I don't think anyone can is going to be bothered with counting up the {} for you Quote Link to comment Share on other sites More sharing options...
RavenStar Posted November 7, 2007 Share Posted November 7, 2007 As suggested by aschk, try getting into the habit of indenting your code, it is easier on the eyes and easier to find errors. From my count, I believe you have not closed two(2) of the { brackets. Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted November 7, 2007 Share Posted November 7, 2007 If you indent your code it will make things alot easier. <?php require_once('operate.php'); checkUser(); ?> <link href="style.css" rel="stylesheet" type="text/css"> <?php //Filename $file_name = $HTTP_POST_FILES['ufile']['name']; //Rename $random_digit = ("excursion.pdf"); //Create new name $new_file_name=$random_digit; $max_size = "500"; $extension = pathinfo($_FILES['ufile']['name']); $extension = $extension[extension]; $allowed_paths = explode(", ", $allowed_ext); for($i = 0; $i < count($allowed_paths); $i++) { if ($allowed_paths[$i] == "$extension") { $ok = "1"; } } if ($ok == "1") { if($_FILES['ufile']['size'] > $max_size) { print "File size is too big!"; exit; } $path= "/path/".$new_file_name; if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "<span class=main><body bgcolor=#CC9933><table width=383 height=286 border=1 align=center bordercolor=#666666> <tr><td width=377 colspan=2 valign=top bgcolor=#666666><p align=center class=title><img src=img/top.png width=608 height=110 /></p> <font color=#FFFFFF size=1 face=verdana><center>Your file has been uploaded successfully! <br /><br /><a href=logout.php>Logout</a></center></font> </td></tr> </table></body><p align=center class=main>Website Designed by </p></span>"; //Display new name for testing, Delete when implementing! echo "File Name :".$new_file_name."<BR/>"; }} else { echo "<span class=main><body bgcolor=#CC9933><table width=383 height=286 border=1 align=center bordercolor=#666666> <tr><td width=377 colspan=2 valign=top bgcolor=#666666><p align=center class=title><img src=img/top.png width=608 height=110 /></p> <font color=#FFFFFF size=1 face=verdana><p><center>Incorrect file extension!<br /><br /><a href=action.php>Try Again</a><br /><a href=logout.php>Logout</a></center></p></font> </td></tr> </table></body><p align=center class=main></p></span>"; } } ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted November 7, 2007 Share Posted November 7, 2007 Get a Free Editor that will show you missing matching {} [] () <> Quote Link to comment Share on other sites More sharing options...
Zane Posted November 7, 2007 Share Posted November 7, 2007 you're missing the last two brackets at the very end EDIT: nevermind I noticed here echo "File Name :".$new_file_name.""; }} else you have two brackets following eachother is that intentional Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted November 7, 2007 Author Share Posted November 7, 2007 Sorry guys, the reason i posted without indents is because i wanted to make sure there was no whitespace at all. Thanks for the help, will test again tommorow with your suggestions. Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.