Jump to content

unexpected T_STRING


jeff5656

Recommended Posts

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;

 

Link to comment
https://forums.phpfreaks.com/topic/144687-unexpected-t_string/
Share on other sites

$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.

Link to comment
https://forums.phpfreaks.com/topic/144687-unexpected-t_string/#findComment-759221
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/144687-unexpected-t_string/#findComment-759233
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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