I need help in displaying my images from the directory images on my public_html directory. It's been uploaded, but it doesn't appear when I run the below php script. Please does anyone know why?
<?php
include_once("connect.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="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
//Retrieves data from MySQL
$data = mysql_query("SELECT * FROM authors") or die(mysql_error());
//Puts it into an array
while($info = mysql_fetch_array( $data ))
{
Echo "<img src=http://giveaway.comli.com/public_html/images/".$info['photo']."> <br>";
Echo "<b>Name:</b> ".$info['name'] . "<br> ";
Echo "<b>Title:</b> ".$info['title'] . " <br>";
Echo "<b>Phone:</b> ".$info['description'] . " <br>";
Echo "<b><a href=".$info['url'] . ">Link</a><br>";
Echo "<b>Country:</b> ".$info['country'] . " <hr>";
}
?>
</body>
</html>
Is your public_html
directory really not your site's document root? Perhaps you mean to say:
Echo "<img src=http://giveaway.comli.com/images/".$info['photo']."> <br>";
Where /images
is a directory at the site document root. In a typical hosting situation, public_html
would be the site document root, meaning that referenced from the web (rather than the file system), it is /
.
What is the document root of your site? I'm guessing it's /home/.../public_html
, which means the URL to access the images would really be http://giveaway.comli.com/images
. Absolute urls of the sort you're using are really only necessary if you're using multiple different hosts/servers for your site, and/or are intending for the html to be portable. You could probably get away with using just <img src="/images/...">
.
As I can see your document roo directory is public_html
, so URL path to your photo will be look like this $image_url = "/images/" . $info['photo'];