|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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> |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
Quote:
okay i corrected that but i'm still getting the error |
|
#4
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Parse error: parse error, unexpected $ |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|