我必須說我是一個真正的初學者,所以請牢記這一點。我目前在這裏工作的本地服務器,我的問題在於,我試圖添加一個圖片到我的PHP代碼,並不真正知道如果問題來自MySQL或從實際的代碼。無法用php和mysql顯示圖像
在MySQL中它是200 varchar,而它的命名:products_image
我的代碼看起來是這樣的:
<!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="text/html; charset=utf-8" />
<title>Releases</title>
</head>
<body>
<?php
require 'database_connection.php';
$select_query = "SELECT * FROM releases";
$result = mysql_query($select_query);
if ($result) {
$row = mysql_fetch_array($result);
$products_name = $row['products_name'];
$products_title = $row['products_title'];
$products_description = $row['products_description'];
$products_image = $row['products_image'];
} else {
die("Error locating user with ID {$user_id}");
}
echo"{$products_name} {$products_title} {$products_description} ";
echo "<img src=\"$products_image.\">";
?>
</body>
</html>
當我看着自己的源代碼,它告訴我這個對圖像部分:
<img src="C:\wamp\www\chaosruralenew\images\kalsahnikovdreams.jpg.">
感謝您的幫助。
絕對或相對路徑不會有所作爲。 – Kermit 2013-03-11 01:38:52
我曾嘗試過,它給了我一個破碎的圖像,當我點擊它時,它的路徑變爲: http://localhost/chaosruralenew/scripts/chaosruralenew/images/kalsahnikovdreams.jpg – 2013-03-11 01:41:26
他正在使用的路徑是隻從服務器有效。在其他電腦上的任何用戶將不會有圖像文件 – Ateszki 2013-03-11 01:42:32