0

我正在尝试在数据库中保存图像文件名,但我无法做到,请帮助我我的数据库没有错误,不知道为什么它无法更新到数据库,但我可以正确获取 $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.";
} 
}
4

1 回答 1

0

因为您的查询不正确

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

试试这个,因为你在 Adminpic 之后使用了 double equal 。

于 2013-07-11T22:12:49.547 回答