gpt4 book ai didi

PHP 错误 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

转载 作者:搜寻专家 更新时间:2023-10-30 23:41:12 24 4
gpt4 key购买 nike

<分区>

我正在我的门户中创建一个单独的页面,从中我可以将图像上传到我的数据库。但是在提交图片时我收到以下错误:

"error in INSERT into 'images_tbl' ('images_path','submission_date') VALUES ('images/24-01-2016-1453612538.jpg','2016-01-24') 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 ('images/24-01-2016-14' at line 1"

我在 saveimage.php 文件中收到此错误。为什么会出现这个错误?

这是我的 HTML 代码:

<html>
<head>
<title>Image Upload</title>
</head>
<body>
<form action="saveimage.php" enctype="multipart/form-data" method="post">
<table style="border-collapse: collapse; font: 12px Tahoma;" border="1" cellspacing="5" cellpadding="5">
<tbody>
<tr>
<td>
<input name="uploadedimage" type="file">
</td>
</tr>

<tr>
<td>
<input name="Upload Now" type="submit" value="Upload Image">
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>

我的 saveimage.php 文件的 PHP 代码:

<?php
include("mysqlconnect.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 = "images/".$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");
}
}
?>

我的 mysqlconnect.php 文件的代码是:

<?php
/**********MYSQL Settings****************/
$host="localhost";
$databasename="demo";
$user="root";
$pass="";
/**********MYSQL Settings****************/

$conn=mysql_connect($host,$user,$pass);

if($conn)
{
$db_selected = mysql_select_db($databasename, $conn);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
}
else
{
die('Not connected : ' . mysql_error());
}
?>

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com