使用PHP错误在数据库中存储图像

我想在PHP中创建个人资料页面,我应该显示登录用户的信息,包括用于此目的的个人资料照片.我想将上传的图像存储在数据库中.我编写了脚本,但它在sql语句中给了我一些错误.

我的PHP脚本

<?PHP
include("configdb.PHP");
    function GetimageExtension($imagetype)
     {
       if(empty($imagetype)) return false;
       switch($imagetype)
       {
           case 'image/bmp': return '.bmp';
           case 'image/gif': return '.gif';
           case 'image/jpeg': return '.jpg';
           case 'image/png': return '.png';
           default: return false;
       }
     }
if (!empty($_FILES["uploadedimage"]["name"])) {
    $file_name=$_FILES["uploadedimage"]["name"];
    $temp_name=$_FILES["uploadedimage"]["tmp_name"];
    $imgtype=$_FILES["uploadedimage"]["type"];
    $ext= GetimageExtension($imgtype);
    $imagename=date("d-m-Y")."-".time().$ext;
    $target_path = "../Photos/".$imagename;
if(move_uploaded_file($temp_name, $target_path)) {
    $query_upload="INSERT into 'images_tbl' ('images_path','submission_date') VALUES
('".$target_path."','".date("Y-m-d")."')";
    MysqL_query($query_upload) or die("error in $query_upload == ----> ".MysqL_error()); 
}else{
   exit("Error While uploading image on the server");
}
}
?>;

我收到了以下错误

error in INSERT into ‘images_tbl’ (‘images_path’,’submission_date’) VALUES (‘../Photos/03-10-2016-1475478958.jpg’,’2016-10-03′) == —-> You have an error in your sql Syntax; check the manual that corresponds to your MysqL server version for the right Syntax to use near ”images_tbl’ (‘images_path’,’submission_date’) VALUES (‘../Photos/03-10-2016-14’ at line 1**

解决方法:

你正在混合MysqLi和MysqL尝试这样

 $query_upload="INSERT into images_tbl (`images_path`,`submission_date`) VALUES
('".$target_path."','".date("Y-m-d")."')";    
MysqLi_query($conn,$query_upload) or die("error in $query_upload == ----> ".MysqLi_error($conn)); 

代替

 $query_upload="INSERT into 'images_tbl' ('images_path','submission_date') VALUES
('".$target_path."','".date("Y-m-d")."')";
    MysqL_query($query_upload) or die("error in $query_upload == ----> ".MysqL_error()); 

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...