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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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