Parse Error in PHP

Reply

Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Parse Error in PHP

 
0
  #1
Sep 21st, 2005
Hi Everybody!

I'm trying to run the following script but I get this error:
Parse error: parse error, unexpected $ in c:\phpdev5\www\public\in.php on line 51
Any help would be appreciated.

Here are the files:

in.php (where the error is coming form):
[PHP]<html>
<head>
<title>CinnaHost Login</title>
</head>
<body bgcolor="#3366FF">
<center><h1><font color="#FFFFFF">Uploading...</font></h1>
<h2><font color="#FFFFFF">To Upload More Files, Click <a href="login.php"><font color="#FFFFFF">Here</font></a>.</font></h2>
</h1></center>


<?php
$filename = "../public/$_POST[site]/pswrd.pswrd";
$fp = fopen($filename,"r") or die ("Login Not Working - please try again.");
$pswrd = fgets($fp);
$attempt = "$_POST[password]";
$display_block = "";

if($pswrd == $attempt) {
echo "Login Successful!";

if("$_POST[uploadfile]" != "") {
//UPLOADING
$file_dir = "$_POST[uploadfile]";
foreach($_FILES as $file_name => $file_array) {
$display_block .= "File Path: ".$file_array['tmp_name']."<br>\n";
$display_block .= "Name: ".$file_array['name']."<br>\n";
$display_block .= "Type: ".$file_array['type']."<br>\n";
$display_block .= "Size: ".$file_array['size']."<br>\n";

if (is_uploaded_file($file_array['tmp_name'])) {
move_uploaded_file($file_array['tmp_name'],
"$file_dir/#file_array['name']") or die("Upload Failed. Possible reasons: file already exists.");
$display_block .= "<br><h3>FILE SUCCESSFULLY UPLOADED!</h3>";

echo $display_block;
}

}

}

if("$_POST[filetodelete]" != "") {
//DELETING
}
}
else {
echo "Login Failed - please try agin.";
}
?>



</body>
</html>[/PHP]

login.php (where the forms are):
[PHP]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CinnaHost Login</title>
</head>

<body bgcolor="#3366FF">
<img src="logo.png" width="939" height="61" />
<br />
<table width="940" height="215" border="1">
<tr>
<td width="103" height="209"><center>
<h3>CinnaHost<br />
<br />
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20">
<param name="BGCOLOR" value="#3366FF" />
<param name="movie" value="button1.swf" />
<param name="quality" value="high" />
<embed src="button1.swf" width="100" height="20" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#3366FF" ></embed>
</object>
<br />
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20">
<param name="BGCOLOR" value="#3366FF" />
<param name="movie" value="button4.swf" />
<param name="quality" value="high" />
<embed src="button4.swf" width="100" height="20" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#3366FF" ></embed>
</object>
<br />
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20">
<param name="BGCOLOR" value="#3366FF" />
<param name="movie" value="button2.swf" />
<param name="quality" value="high" />
<embed src="button2.swf" width="100" height="20" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#3366FF" ></embed>
</object>
<br />
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20">
<param name="BGCOLOR" value="#3366FF" />
<param name="movie" value="button3.swf" />
<param name="quality" value="high" />
<embed src="button3.swf" width="100" height="20" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#3366FF" ></embed>
</object>
<br />
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20">
<param name="BGCOLOR" value="#3366FF" />
<param name="movie" value="button5.swf" />
<param name="quality" value="high" />
<embed src="button5.swf" width="100" height="20" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#3366FF" ></embed>
</object>
</h3>
</center></td>
<td width="821" bgcolor="#0000FF"><center>
<h2>CinnaHost Login/Upload:</h2>
</center>
<form action="in.php" method="post" enctype="multipart/form-data">
<p><strong> <font color="#FFFFFF">Site Name:</font><br />
<input name="site" type="text" />
<br />
<br />
<font color="#FFFFFF">Password:</font><br />
<input type="password" name="password" />
</strong><strong></strong>
<strong> <br />
<br />
<font color="#FFFFFF">File To Upload: If Not Uploading, Leave Blank.</font>
<br />
<input type="hidden" name="MAX_FILE_SIZE" value="51200" />
<input type="file" name="fileupload" />
<br />
<br />
<font color="#FFFFFF">If Deleting A File, Enter The Exact File Name (and extension). If Not Deleting, Leave Blank.</font><br />
<input type="text" name="filetodelete" />
<br />
<br />

<input type="submit" value="Login and Upload" />
</strong></p>
</form></td>
</tr>
</table>
</body>
</html>
[/PHP]
Last edited by Ghost; Sep 21st, 2005 at 2:29 am. Reason: forgot to insert login.php
Reply With Quote Quick reply to this message  
Join Date: Jan 2004
Posts: 93
Reputation: fsn812 is an unknown quantity at this point 
Solved Threads: 1
fsn812's Avatar
fsn812 fsn812 is offline Offline
Junior Poster in Training

Re: Parse Error in PHP

 
0
  #2
Sep 21st, 2005
Not sure why you are getting the $ end of file notation error, all your brackets seem to be in order (of course I didn't check that closely but they appear to be in order).

Is the name='uploadfile' (login.php) meant for "$POST[fileupload]" (in.php)?

Also, in case you get an 'Undefined Index' error with $POST['fileupload'] ("$POST[fileupload]" as you have it listed) you may want to change:

  1. if("$_POST[uploadfile]" != "") {

to

  1. if(isset($_POST['fileupload'])) {
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: Parse Error in PHP

 
0
  #3
Sep 22nd, 2005
I tried that, but I'm still getting that error. Any other suggestions? Also, should I used $_POST['blank'] instead of $_POST[blank]? Thanks.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 138
Reputation: sarahk is an unknown quantity at this point 
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: Parse Error in PHP

 
0
  #4
Sep 22nd, 2005
I would also recommend changing
  1. $filename = "../public/$_POST[site]/pswrd.pswrd";
to
  1. $filename = "../public/{$_POST['site']}/pswrd.pswrd";
what you had looks like it should be ok but it's better to be safe with arrays.

No obvious errors though...
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: Parse Error in PHP

 
0
  #5
Sep 22nd, 2005
Thanks SarahK! It worked!!! Now, I have one more problem - it says the file was uploaded, but where was it uploaded to? Here's my upload code:

[PHP]$file_dir = "$_POST[uploadfile]";
foreach($_FILES as $file_name => $file_array) {
$display_block .= "File Path: ".$file_array['tmp_name']."<br>\n";
$display_block .= "Name: ".$file_array['name']."<br>\n";
$display_block .= "Type: ".$file_array['type']."<br>\n";
$display_block .= "Size: ".$file_array['size']."<br>\n";

if (is_uploaded_file($file_array['tmp_name'])) {
move_uploaded_file($file_array['tmp_name'],
"$file_dir/#file_array['name']") or die("Upload Failed. Possible reasons: file already exists.");
$display_block .= "<br><h3>FILE SUCCESSFULLY UPLOADED!</h3>";

echo $display_block;
}

} [/PHP]

Also, I want to upload the file in $_POST[sitename]/uploaded_file.html. Is my code correct?

Once again, THANK YOU SO MUCH!!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC