Jump to content

Need a second pair of eyes!


Schlo_50

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/76379-need-a-second-pair-of-eyes/
Share on other sites

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

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.