當我試圖在一個單獨的分區中回顯它時,從MySQL服務器中選擇一個jpg圖像後,當我使用這個時出現ascii字符的混雜:'在一個div中回顯一個圖像在php中失敗
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="image/jpeg; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<div id = "myDiv">
<h2>Div</h2>
<?php
require_once('appvars.php');
require_once('connectvars.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$id = 1;
$query = "SELECT image FROM images WHERE id=?";
$stmt = $dbc->prepare($query);
$stmt->bind_param("i",$id);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($image);
$stmt->fetch();
echo $image;
?>
</div>
</body>
</html>
在此先感謝您的幫助!
將其嵌入到頁面中我非常確定'echo $ image;'完美地工作。也許你應該寫下你想問的問題? (非常好意味着它出現爲ASCII字符的混雜,所以這是正確的。如果計算機上的東西不會在可接受的邊界上被破壞)。 – hakre 2012-04-17 00:42:11
我想知道是否有數據庫中的圖像路徑周圍的HTML代碼。 – Philipp 2012-04-17 00:43:28