gpt4 book ai didi

php - 上传到数据库失败

转载 作者:行者123 更新时间:2023-11-30 01:29:53 24 4
gpt4 key购买 nike

我正在尝试将图像文件名保存在数据库中,但我无法成功,请帮助我我的数据库没有错误,不知道为什么它无法更新到数据库,但我可以正确获取 $newname

?php session_start(); 
include_once("connectDB.php");
$ID = $_SESSION['ID'];

if(isset($_POST['upload'])){
$ID = $_SESSION['ID'];
$loc = "profilepicture/";

if($_FILES["Adminpic"]["type"] == "image/png" || $_FILES["Adminpic"]["type"] ==
"image/jpeg" || $_FILES["Adminpic"]["type"] == "image/jpg" || $_FILES["Adminpic"]
["type"] == "image/gif")
{
$ID = $_SESSION['ID'];
$file = explode(".", $_FILES["Adminpic"]["name"]);
$newname = "$ID.$file[0].$file[1]";
mysql_query("UPDATE admin SET Adminpic == '$newname' WHERE ID='$ID'");


$path = "$loc$newname";
move_uploaded_file($_FILES["Adminpic"]["tmp_name"], $path) ;
echo "Your image has been uploaded success, $newname";

}
else{
echo"invalid file.";
}
}

最佳答案

因为您的查询不正确

  mysql_query("UPDATE admin SET Adminpic ='$newname' WHERE ID=$ID");

尝试这样做,因为您在 Adminpic 之后使用了双等号。

关于php - 上传到数据库失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17604373/

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