Array
(
[0] => Picture141.jpg
[name] => Picture141.jpg
)
mysql_fetch_assoc() should get rid of the double entries if not needed.
Okay, so the value is correct. The script works - when the script prints out normally, what is the HTML source it prints? Also try replacing the relative xml/ path with the full path, e.g.
http://www.example.com/xml/
Finally - reformat the img tag for XHTML compliance...
echo '<img src="xml/' . $row['name'] . '">';
It's often useful to create a constant for the full route in your scripts - this prevents any relative path errors. For example, if I put a PHP index.php file at
http://www.example.com/MyApp/ and I want this uri to be my base URL for all links/image src's I can create a constant for use in all scripts with:
Code: Select all
// clean the PHP_SELF value (prevent XSS via Apache mod_rewrite)
$self = basename(__FILE__);
$_SERVER['PHP_SELF'] = substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], $self)) . $self;
// calculate the URL (without filename)
$self = $_SERVER['PHP_SELF'];
$parts = explode("/", $self);
$nofilename = array_pop($parts);
$thisurl = implode("/", $parts);
// define the URLROOT with trailing slash
define('URLROOT', $thisurl . '/');