我的数据库有一个表(a),其中我有一个id作为PK和一个图像表(output_images),其内容id来自(a)作为外键。
output_images表:
image_id tinyint(3) NOT NULL AUTO_INCREMENT,
image_type varchar(25) NOT NULL,
imageData mediumblob BINARY
a_ID int(11)
image.php 从数据库中获取每张图片:
<?php
mysql_connect("... .com","user","pw");
mysql_select_db("database");
if(isset($_GET['image_id'])) {
$sql = "SELECT imageType,imageData FROM output_images, a WHERE
output_images.a_ID=a.a_ID" . $_GET['image_id'];
$result = mysql_query("$sql") or die("<b>Error:</b> Problem on Retrieving Image BLOB<br/>" . mysql_error());
$row = mysql_fetch_array($result);
header("Content-type: " . $row["imageType"]);
echo $row["imageData"];
}
mysql_close();
?>
listimages.php 调用image.php来构建图片列表:
<?php
mysql_connect("... .com","user","pw");
mysql_select_db("database");
$sql = "SELECT imageId FROM output_images,a Where output_images.a_ID=a.a_ID ORDER BY imageId DESC";
$result = mysql_query($sql);
?>
<HTML>
<HEAD>
<TITLE>List BLOB Images</TITLE>
<link href="imageStyles.css" rel="stylesheet" type="text/css" />
</HEAD>
<BODY>
<?php
while($row = mysql_fetch_array($result) or die (mysql_error())
{
?>
<img src="image.php?image_id=<?php echo $row["imageId"]; ?>" /><br/>
<?php
}
mysql_close();
?>
</BODY>
</HTML>
实际错误讯息:
解析错误:语法错误,意外'{'in home / a9996478 / public_html / listImages.php on line 15
如果我将listImages.php的第五行更改为:
$sql = "SELECT imageId FROM output_images ORDER BY imageId DESC";
我遇到了同样的问题,即使我也在此之前获得了12行破碎的图片
我不知道这个问题是什么......
答案 0 :(得分:1)
在while循环中缺少)
while($row = mysql_fetch_array($result) or die (mysql_error()) )// missing