PHP Syntax Check: Parse error: syntax error? [closed]

i get this error when using my php code

PHP Syntax Check: Parse error: syntax error, unexpected ‘}’ in your code on line 7

please help me i dont understand what ive done wrong here
php code :

<?php


if ( $ready == "false" ) { 
$rand =  chr(rand(97, 122)). chr(rand(97, 122)). chr(rand(97, 122)); 
$folder = "uploads/".$rand 
}

if ( !is_dir($folder) ) {
    $ready = "true"
}
if ( is_dir($folder) ) {
    $ready = "false"
}

if ( $ready == "true" ) {
$that = "yes"
mkdir("uploads/".$rand);
$to = "Uploads/".$_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"], $to);
echo "uploaded";
}
?>


<form method="post" enctype="multipart/form-data">
<label>Choose a file:</label>
<input type="hidden" name="upload" value="1">
<input type="file" name="file">
<input type="submit" value="upload" onclick="$other = "yes""/>

</form>

Comments 2

  • You have miss ; in many lines complete code:

    if ( $ready == "false" ) { 
      $rand =  chr(rand(97, 122)). chr(rand(97, 122)). chr(rand(97, 122)); 
      $folder = "uploads/".$rand ;
    }
    
    if ( !is_dir($folder) ) {
        $ready = "true";
    }
    if ( is_dir($folder) ) {
        $ready = "false";
    }
    
    if ( $ready == "true" ) {
      $that = "yes";
      mkdir("uploads/".$rand);
      $to = "uploads/".$_FILES["file"]["name"];
      move_uploaded_file($_FILES["file"]["tmp_name"], $to);
      echo "uploaded";
    }
    
  • you forgot a semicolon at the end of line 7. The statement is not complete, so the parser does not expect the curly bracket.

    if ( $ready == "false" ) { 
        $rand =  chr(rand(97, 122)). chr(rand(97, 122)). chr(rand(97, 122)); 
        $folder = "uploads/".$rand ;
    }
    

发表评论

电子邮件地址不会被公开。 必填项已用*标注