用php和mysql无法显示图像 [英] Can't show image with php and mysql
问题描述
我必须说我是一个真正的初学者,所以记住这一点。我目前在这里工作本地服务器,我的问题是我正在尝试将图片添加到我的PHP代码中,并且不知道问题是来自mysql还是来自实际代码。
I must say that i'm a real beginner in this so keep that in mind. I'm currently working on a local server here and my problem here is that i'm trying to add a picture to my php code and don't really know if the problem come from mysql or from the actual code.
它的varchar是200,它的名字是:products_image
in mysql it's a varchar of 200 and it's named: 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>
当我查看我的源代码时,它会向我显示图像部分:
And when i look at my source code it show me this for the image part:
<img src="C:\wamp\www\chaosruralenew\images\kalsahnikovdreams.jpg.">
感谢您的帮助。
推荐答案
您正在使用服务器文件系统的本地路径。
You are using a local path to the server filesystem.
您应该保存相对于您的网站机器人的路径。
You should save the path relative to your website robot.
chaosruralenew/images/kalsahnikovdreams.jpg
这篇关于用php和mysql无法显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!