我必须说我是一个真正的初学者,所以请牢记这一点。我目前在这里工作的本地服务器,我的问题在于,我试图添加一个图片到我的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