PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 9th, 2005, 12:55 PM
webNerd webNerd is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 17 webNerd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 22 m 43 sec
Reputation Power: 0
Question Parse error: parse error, unexpected $

i'm getting this error:
Parse error: parse error, unexpected $ in /www/html/login/file_upload_manager.php on line 168

but there no php code on 168 it just my closing </html> tag on that line.

what do i look for?
i'm working from this tutorial.
www.devarticles.com/c/a/PHP/File-Version-Management-in-PHP/2/

<?php

if($upload) {
if(upload_file != "none") {

$file_path = $dir_path.$upload_file_name;

$upload_file_parts = pathinfo($upload_file_name);
$upload_file_extn = $upload_file_parts["extension"];
/* filesize() get file size */
$upload_file_size = file_size(filesize($upload_file));
$upload_file_type = $upload_file_parts["extension"];
/* filemtime() get the time when the file was modified */
$upload_file_modified = date("M d, Y", filemtime($upload_file));
$upload_file_date = filemtime($upload_file);
/* explode() split string by string */
/* list() assign variables as if they were an array */
/* basename returns filename component of path
basename(string path [, string suffix]) for ex
$path = "/html/www/index.php";
basename($path); it will get "index.php"
basename($path, ".php") it will get "index" (if the filename ends in suffix it will be cut off) */
list($file_name,$junk) = explode(".",$upload_file_parts["basename"]);

/* file_exists() checks whether a file or directory exist */
if(file_exists($file_path)) {
if($replace) {
/* copy() copies file */
if(copy($upload_file,$file_path)) {
$sql_query = "UPDATE file_manager SET file_size = '$upload_file_size', file_modified = '$upload_file_modified' WHERE file_image_name = 'upload_file_name'";
$file_result = mysql_query($sql_query);
/* mysql_query() returns the text or error messages from the mysql query */
if(!mysql_error()) {
$status = "File Replaced Successfully";
$url = "file_display_manager.php";
redirect($status,$url);
} else {
$status = "MySQL Error: <br />" .mysql_error();
$url = "file_upload_manager.php";
redirect($status,$url);
}
}
} else {
$rem_file_parts = pathinfo($file_path);
$rem_file_size = file_size(filesize($file_path));
$rem_file_type = $rem_file_parts["extension"];
$rem_file_date = filemtime($file_path);

if($upload_file_size != $rem_file_size && $upload_file_date != $rem_file_date) {
$new_file_name = get_new_file_name($file_name);

$new_file_name = $new_file_name.".".$upload_file_extn;
$copy_path = $dir_path.$new_file_name;

if(copy($upload_file, $copy_path)) {
$sql_query = "INSERT INTO file_manager (file_name, file_type, file_size, file_modified, file_parent_id, file_image_name)
VALUES ('$upload_file_name','$upload_file_type','$upload_ file_size','$upload_file_modified',1,'$new_file_na me')";
$file_result = mysql_query($sql_query);

if(!mysql_error()) {
$status = "File Uploaded Successfully";
$url = "file_display_manager.php";
redirect($status,$url);

} else {
$status = "MySQL Error: <br />".mysql_error();
$url = "file_upload_manager.php";
redirect($status,$url);
}
} else {
$status = "File Copy Operation Failed";
$url = $hostname."file_upload_manager.php";
redirect($status,$url);
}
} else {
$status = "A previous version of this file exists.";
$url = "file_upload_manager.php";
redirect($status,$url);
}
}
} else {
if(copy($upload_file, $dir_path.$upload_file_name)) {
$sql_query = "INSERT INTO file_manager (file_name, file_type, file_size, file_modified, file_parent_id, file_image_name)
VALUES ('$upload_file_name','$upload_file_type','$upload_ file_size','$upload_file_modified',0,'$upload_file _name')";

$file_result = mysql_query($sql_query);
if(!mysql_error()) {
$status = "File Uploaded Successfully";
$url = "file_display_manager.php";
redirect($status,$url);
} else {
$status = "MySQL Error: <br />".mysql_error();
$url = "file_upload_manager.php";
redirect($status,$url);
}
} else {
$status = "File Copy Operation Failed";
$url = "file_upload_manager.php";
redirect($status,$url);
}
}
} else {
$errMsg = "You must select a file to upload!";
display_form($errMsg);
}
} else {
$errMsg = "";
display_form($errMsg);
}

function display_form($errMsg) {
global $dir_path;


?>

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


</head>
<body>

<h3>File Manager</h3><br>

<?php if($errMsg) { ?>
<?php echo $errMsg ?>



<form action="<?php echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data">




File Location<br>
<input type="file" name="upload_file" value="Browse"><br>
<input type="checkbox" name="replace" value="1">*Overwrite File

<input type="submit" name="submit" value="Upload"><input type="reset" name="reset" value="Cancel"><p>

*This option will overwrite any existing file.<br>
<a href="file_display_manager.php">File Manager</a><br>
<?php if ($status) { echo "file_result :".$status; } ?>
<b>Folder Location:</b> <?php echo $dir_path ?>


</form>




</body>
</html>

Reply With Quote
  #2  
Old February 9th, 2005, 01:09 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 5
In the future, please enclose code in php tags (using the php icon in the upper right) -- it makes it much easier to read. Also, try to only post as much code as is necessary -- people may skip questions with half a page of untagged code.

In this case, it looks like you're last echo $dir_path line doesn't have its ending semicolon.

Reply With Quote
  #3  
Old February 9th, 2005, 01:18 PM
webNerd webNerd is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 17 webNerd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 22 m 43 sec
Reputation Power: 0
Quote:
Originally Posted by Madpawn
In the future, please enclose code in php tags (using the php icon in the upper right) -- it makes it much easier to read. Also, try to only post as much code as is necessary -- people may skip questions with half a page of untagged code.

In this case, it looks like you're last echo $dir_path line doesn't have its ending semicolon.


okay i corrected that but i'm still getting the error

Reply With Quote
  #4  
Old February 9th, 2005, 01:23 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 5
Go back through your code and make sure you're not missing any more semicolons or closing function/statement brackets (}). Those parse errors are usually caused by a line or block not being properly closed.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Parse error: parse error, unexpected $


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT