0
我知道我使用的是折旧的MySQL,页面会非常沉重,我应该将图像文件链接到数据库中,而不是直接在那里插入它们。 除此之外,我无法在列“image”中的数据库表“builds”中显示BLOB图像。用PHP显示MySQL数据库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);
感谢您的帮助,我一直在挣扎了这一小时。
索引图像试试这个链接(http://stackoverflow.com/questions/20556773/php-display-image-blob-from-mysql) – developersaumya
@SaumyaSingh我试过这个,我仍然卡住了。 – Aramza
告诉我们什么是你面临的错误或问题? – developersaumya