-2
//setting veriables
$imagestring = $_FILES["file"]["name"];
$myuser = $_POST['myusername'];
//mysql set up error handle
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$chkuserid = mysql_query("select UserID from users where Username = '".$myuser."'");
$row = mysql_fetch_array($chkuserid);
$finall = $row['UserID'];
// putting data into database
var_dump($finall);
$sql="UPDATE users SET avatarstring='k00138899.atspace.eu/photoalbum/upload/".$imagestring."' WHERE UserID='".$finall."'";
我想我試圖在用戶表我的一切都avatarstring將路徑存儲圖像,如果上傳成功更新報表數據不進入DB
用戶標識 - 一個int(25)
$ finall - 字符串
avatarstring - TEXT
文件上傳,但圖像地址的條目應與avatarstring列一起進行此操作。上傳影像作品
碼和驗證碼放在裏面,如果上載工作沿着顯示語句全成這個代碼消息說圖片上傳成功
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"avatar/" . $_FILES["file"]["name"]);
echo "Stored in: " . "avatar/" . $_FILES["file"]["name"];
// if upload successful add entry into DB
$host="fdb4.atspace.com:3306"; // Host name
$username="1259829_photo"; // Mysql username
$password="j8"; // Mysql password
$db_name="1259829_photo"; // Database name
$tbl_name="users"; // Table name
//setting veriables
$imagestring = $_FILES["file"]["name"];
$myuser = $_POST['myusername'];
//mysql set up error handle
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$chkuserid = mysql_query("select UserID from users where Username = '".$myuser."'");
$row = mysql_fetch_array($chkuserid);
$finall = $row['UserID'];
// putting data into database
var_dump($finall);
var_dump($myuser);
$sql="UPDATE users SET avatarstring='k00138899.atspace.eu/photoalbum/upload/".$imagestring."' WHERE Username='".$myuser."'";
}
}
}
else
{
echo "Invalid file";
}
?>
總是使用'mysqli_error',將節省您的時間調試您的查詢 –
您是否執行更新查詢? – RafH
在你的代碼中,你把圖像保存在你的系統上?如果2張圖像具有相同的名稱,那麼您使用的代碼會造成麻煩。 –