jeff5656 Posted February 10, 2009 Share Posted February 10, 2009 I get this error: Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in /home/etc/html/micro-test.php on line 65 <?php if (isset($_POST['submitBtn'])){ ?> <div id="caption">RESULT</div> <div id="icon2"> </div> <div id="result"> <table width="100%"> <?php $basename = basename($_FILES['upfile']['name']); $filename = (substr_count(".html",$basename) > 0 ) ? $ substr_replace($basename,"",-1); :vbasename; $target_path = $uploadLocation .$filename; if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path)) { echo "The file: ". basename( $_FILES['upfile']['name']). " has been uploaded!"; } else{ echo "There was an error uploading the file, please try again!"; } ?> </table> </div> <?php } ?> note: Line 65 is this one: $filename = (substr_count(".html",$basename) > 0 ) ? $ substr_replace($basename,"",-1); :vbasename; Quote Link to comment https://forums.phpfreaks.com/topic/144687-unexpected-t_string/ Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 $filename = (substr_count(".html",$basename) > 0 ) ? substr_replace($basename,"",-1) : $vbasename; Try that, you had a $ in there when you did not need one and a ; after the substr_replace statement, which is not needed. I assumed vbasename needed the $ so I added it there. Quote Link to comment https://forums.phpfreaks.com/topic/144687-unexpected-t_string/#findComment-759221 Share on other sites More sharing options...
The Little Guy Posted February 10, 2009 Share Posted February 10, 2009 I believe you want to change this: $filename = (substr_count(".html",$basename) > 0 ) ? $ substr_replace($basename,"",-1); :vbasename; to this: $filename = (substr_count(".html",$basename) > 0 ) ? substr_replace($basename,"",-1) : $vbasename; Quote Link to comment https://forums.phpfreaks.com/topic/144687-unexpected-t_string/#findComment-759222 Share on other sites More sharing options...
jeff5656 Posted February 10, 2009 Author Share Posted February 10, 2009 Ok I changed that line and now when I submit the file I get this error: Warning: move_uploaded_file(schedules/): failed to open stream: Is a directory in /home/content/j/e/f/etc/html/micro-test.php on line 69 Warning: move_uploaded_file(): Unable to move '/tmp/phpbOlRZO' to 'schedules/' in /home/content/j/e/f/etc/html/micro-test.php on line 69 There was an error uploading the file, please try again! Here is the code: $uploadLocation = "schedules/"; <body> <div id="main"> <div id="caption">UPLOAD STAFF AND FELLOW SCHEDULES</div> <div id="icon"> </div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="fileForm" id="fileForm" enctype="multipart/form-data"> </form> <?php if (isset($_POST['submitBtn'])){ ?> <div id="caption">RESULT</div> <div id="icon2"> </div> <div id="result"> <table width="100%"> <?php $basename = basename($_FILES['upfile']['name']); $filename = (substr_count(".html",$basename) > 0 ) ? substr_replace($basename,"",-1) : $vbasename; $target_path = $uploadLocation .$filename; if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path)) { echo "The file: ". basename( $_FILES['upfile']['name']). " has been uploaded!"; } else{ echo "There was an error uploading the file, please try again!"; } ?> </table> </div> <?php } ?> Note: Line 69 coincides around the if(move_upload.... line As a reminder, I want to change files uploaded as "filename.html" to "filename.htm". If the extension is different (i.e. jpg), leave it alone and don't rename. Quote Link to comment https://forums.phpfreaks.com/topic/144687-unexpected-t_string/#findComment-759233 Share on other sites More sharing options...
jeff5656 Posted February 11, 2009 Author Share Posted February 11, 2009 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/144687-unexpected-t_string/#findComment-759391 Share on other sites More sharing options...
Montiero Posted February 11, 2009 Share Posted February 11, 2009 You're going to need to post everything up to line 69 at least as your problem could relate to something not shown in the code provided. Quote Link to comment https://forums.phpfreaks.com/topic/144687-unexpected-t_string/#findComment-759407 Share on other sites More sharing options...
jeff5656 Posted February 11, 2009 Author Share Posted February 11, 2009 That is the whole code - I just deleted some extraneous lines, like html-related tables and kept all the php code. Quote Link to comment https://forums.phpfreaks.com/topic/144687-unexpected-t_string/#findComment-759473 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.