使用BLOB无法正常工作更新表

时间:2014-04-10 21:52:03

标签: php mysql sql-update blob

现在我正在尝试使用BLOB更新数据库测试和表成员。此BLOB已在上一篇文章中上传。我可以成功插入blob但不更新'image'列为null的行。我怀疑问题是我使用update定义我的SQL查询的地方。有人可以查看我的代码并帮助我找到问题。

<?php
// Create MySQL login values and
// set them to your login information.
$username = "root";
$password = "";
$host = "localhost";
$database = "test";
$tbl_name="members";
$id=6;
// Make the connect to MySQL or die
// and display an error.
$link = mysql_connect($host, $username, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}

// Select your database
mysql_select_db ($database);


// Make sure the user actually
// selected and uploaded a file
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {

// Temporary file name stored on the server
$tmpName = $_FILES['image']['tmp_name'];

// Read the file
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);


// Create the query and insert
// into our database.
$sql2 ="UPDATE $tbl_name SET (image) VALUES ('$data') WHERE id = $id";

$results = mysql_query($sql2, $link);

// Print results
print "Thank you, your file has been uploaded.";

}
else {
print "No image selected/uploaded";
}

// Close our MySQL Link
mysql_close($link);




?>

0 个答案:

没有答案
相关问题