I have a MySQL db with a table, that has the following field:
txtProductBowlImage: example " C:\BowlPhotos\Thumbs\MapleTi07-030tmb.jpg"
I want to use the data in that field to produce an image that I can print to a text file.
I read the data then try to echo it to the screen...and I see a small icon, but no image.
Here's the code:
<?php
$con = mysql_connect("localhost","xxxxxxx","zzzzzzzzzzzzzzz");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("scwdb", $con);
$result = mysql_query("SELECT * FROM tblsplintersbowlinventory WHERE txtVenue = 'Shoreline'");
while($row = mysql_fetch_array($result))
{
echo $row['intProductID'] . " " . $row['txtProductBowlCode'] . " " . $row['txtProductBowlImage'] . "]";
echo "<br />";
echo "<br />";
echo 'txtProductBowlImage: ' . $row['txtProductBowlImage'];
echo "<br />";
$img = $row['txtProductBowlImage'];
echo '...............$img: ' . $img;
echo "<br />";
echo "<img src=" . $img . ">";
echo "<img src='C://BowlPhotos//Thumbs//Ash07-013_btmb.jpg'>";
echo "<img src='Ash07-013_btmb.jpg'>";
echo "<br />";
echo "==================";
echo "<br />";
}
mysql_close($con);
?>
Note that I try 3 times to show an image: 1: using the url from the db and putting it in an echo statement this url uses the '\' separater in the data. 2: imbedding a sample of the actual text path and filename in an echo statement this url uses the '/' separater in the url. 3: imbedding only the filename, no path, in an echo statement
When I run this, I get the following output:
Echo #1 & #2 produce the icon, echo #3 shows a local copy of the image in the same folder as the php.
From this it appears that it is the path that is not being used, either with the '\' or '/' separater.
I assume the '\' may be seen as an escape, but why doesn't the url with the '/' work?
txtProductBowlImage: C:\BowlPhotos\Thumbs\MapleTi07-030tmb.jpg
...............$img: C:/BowlPhotos/Thumbs/MapleTi07-030tmb.jpg
==================
– Stephen Nov 05 '12 at 02:20