【发布时间】:2016-09-01 01:36:06
【问题描述】:
我知道我正在使用折旧的 MySQL,页面会很重,我应该将图像文件链接到数据库中,而不是直接将它们插入那里。 除此之外,我无法在“image”列中显示数据库表“builds”中的 BLOB 图像。
这是我的代码:显示打开和关闭 PHP 标记的问题。
PHPMyAdmin 图片:
网页显示:
include ("connect.php");
$conn = mysql_connect("localhost", $id, $pw); //Start of Establishing Connection to Database "akimble"
if (!$conn) {
die ("Error connecting: " . mysql_error()); //Displays What the Error was if Present
}
mysql_select_db($db, $conn);
$sql = "SELECT * FROM builds"; //Selects Everything From the Table "userinfo" in "akimble" Database
$results = mysql_query($sql, $conn); //Assigning all Data
echo "<table cellpadding=10 border=1>
<tr>
<th>User ID</th>
<th>Image Name</th>
<th>Image</th>
</tr>";
while ($entries = mysql_fetch_array($results)) { //Fetch all Information within "results" Variable
echo "<tr>";
echo "<td>" . $entries['id'] . "</td>";
echo "<td>" . $entries['name'] . "</td>";
header("Content-type: image/jpg");
echo '<img src="data:image/jpg;base64,' . base64_encode( $row['image'] ) . '" />';
echo "</tr>";
}
echo "</table>";
mysql_close($conn);
感谢您的帮助,我为此苦苦挣扎了好几个小时。
【问题讨论】:
-
@SaumyaSingh 我已经尝试过了,但我仍然卡住了。
-
告诉我们您面临的错误或问题是什么??
-
@SaumyaSingh 和以前一样的错误,目前没有显示图像。
-
哦,你为什么用
$row??虽然它不反对你应该使用$entries['image']
标签: php mysql image blob display