0

I have a PHP image upload script which uploads the image data to a MySQL server. It is giving me an unexpected T_VARIABLE, but it appears as I have all of my semicolons present. Can anybody help me out?

<?php
$username = "username";
$description = "description";
// Check if image file is a actual image or fake image

if(isset($_FILES['image'])){ 
    $check = getimagesize($_FILES["image"]["tmp_name"]);

    if($check !== false) {
         echo "File is an image - " . $check["mime"] . ".";
         $uploadOk = 1;
         $image = file_get_contents($_FILES["image"]["tmp_name"]);
         $con = mysqli_connect("localhost", "root", "root", "familyConnections");

         $query = "INSERT INTO images (userName, image, description) VALUES ($username, $image, $description)";
         $query = mysqli_query($con, $query);

         if($query != 0){
               echo "ERROR something went wrong";
         }else {
            echo "IT WORKED".$query;
         }

         } else {
             echo "File is not an image.";
             $uploadOk = 0;
      }
    }
?>

the result I get is

PHP Parse error: syntax error, unexpected '$check' (T_VARIABLE) in /var/www>/html/upload.php on line 7.

NavidIvanian
  • 347
  • 5
  • 15

0 Answers0