我有一个PHP图像上传脚本,它将图像数据上传到MySQL服务器。它给了我一个意想不到的T_VARIABLE,但看起来我的所有分号都存在。有人可以帮帮我吗?
<?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;
}
}
?>
我得到的结果是
PHP解析错误:语法错误,意外&#39; $ check&#39;第7行的/var/www>/html/upload.php中的(T_VARIABLE)。