Php Can';t在MySQL中插入图像

Php Can';t在MySQL中插入图像,php,mysql,Php,Mysql,我正在做一个上传和请求id来检索上传后的图像。然而,在我可以检索之前,我甚至可以将它插入我的MySQL数据库 顺便说一句,问题出在第19行,它是 "$query = "INSERT INTO profilepicture (`id`,`name`,`image`) VALUES ('','".$image_name."','".$image."')";" 这是我使用的代码 <?php $con = mysqli_connect('127.0.0.1', 'root', '', 'tes

我正在做一个上传和请求id来检索上传后的图像。然而,在我可以检索之前,我甚至可以将它插入我的MySQL数据库

顺便说一句,问题出在第19行,它是

"$query = "INSERT INTO profilepicture (`id`,`name`,`image`) VALUES ('','".$image_name."','".$image."')";"
这是我使用的代码

<?php
 $con = mysqli_connect('127.0.0.1', 'root', '', 'test');
$files = $_FILES['uploadProfilePicture']['tmp_name'];

 if(!isset($files)){
echo("wrong file");
 }else
 {
$image = file_get_contents($_FILES['uploadProfilePicture']['tmp_name']);
$image_name = $_FILES['uploadProfilePicture']['name'];
$image_size = getimagesize($_FILES['uploadProfilePicture']['tmp_name']);

if($image_size == false) 
{
    echo("Thats is not an image");
}else
{
    $query = "INSERT INTO profilepicture (`id`,`name`,`image`) VALUES ('','".$image_name."','".$image."')";
    if(!$insert = mysqli_query($con, $query))
    {
    echo("problem uploading");  
    }else
    {

        $lastid = mysql_insert_id();
        echo "image uploaded.</p> Your Image</p> <img src=getImage.php?id=".$lastid.">";
    }
}
 }
 ?>



<div class="loginCheck">
        <div class="profilePicture">
            <form action="ProfileImages/FileUpload.php" method="POST" enctype="multipart/form-data">
                <input  type="file" name="uploadProfilePicture"/> <input type="submit" value="Upload" />
            </form>



        </div>
    </div>

我打赌你对这一行有意见:

$image = file_get_contents($_FILES['uploadProfilePicture']['tmp_name']);
请尝试以下方法:

$image = mysql_real_escape_string(file_get_contents($_FILES['uploadProfilePicture']['tmp_name']));

你需要逃出那根弦。里面可能有一句话。您应该研究如何使用。

这个字符串应该如何构造

"$query = "INSERT INTO profilepicture (`id`,`name`,`image`) VALUES ('','".$image_name."','".$image."')";"
如上所述?或:

$query = "INSERT INTO profilepicture (`id`,`name`,`image`) VALUES ('','".$image_name."','".$image."')";

请注意删除了
$
前面和
末尾的引号

出现了什么错误?