我想在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**
解决方法:
$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());
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。