Forum Moderators: coopster
I have an area where the user can upload an image. Let's say "dog.jpg". the image goes into the MySQL database row encoded like "18783676456776.jpg:dog.jpg" and then the actual IMAGE goes into a folder with just the encrypted name, i.e. 18783676456776.jpg
I am quite certain the CMS decrypts it when it displays it but as I said, I am writing my own output.
Hence when I try to display the image, here is the variable:
$Image = $row['Image'];
and here is the call:
echo "<img src='http://www.mysite.com/articlelive/page_images/$Image' border=1>";
When I call the row from the database it's trying to display 18783676456776.jpg:dog.jpg but of course the image itself is now simply 18783676456776.jpg
What I ewould like to do is STRIP everything from the colon on, so taht when PHP tries to display it, the name it is trying to display matches the name of the actual image in the folder.
Can this be done?
Thanks!
Or another method i can think of is to use the split function like something such as this.
<?
$pattern = ":";
//$new_image would contain stripped string for displ.
list($new_image, $junk) = split($pattern, $image);
?>
the Mysql db holds this info in a row called "Image":
290346193f2f388b9f43494e1ed5af2d.jpg:iprecon_hawkeye_360.jpg
I am using the "split" function in PHP to sepaate the gobblegook at the beginning from the jpg name at the end, as such:
list($a, $b) = split('[:]', $Image);
the actual IMAGE is sitting in a folder called "page_images" but it's named after the gobbldegook:
290346193f2f388b9f43494e1ed5af2d.jpg
Since I have defined the first half of the split as $a, I am trying to call and display the image as follows:
echo "<img src='http://www.example.com/articlelive/page_images/$a' border=1>";
But I am getting nothing.
HELP! This is very maddening and it's got me stopped in my tracks.
Best regards,
Pat
[edited by: jatar_k at 2:42 pm (utc) on June 27, 2007]
[edit reason] please use example.com [/edit]
<?PHP
$Title =$row['Title'];
$Content =$row['Content'];
$PageID = $row['PageID'];
$MetaDesc = $row['MetaDesc'];
$Image = $row['Image'];
list ($a, $b) = explode(":", $Image);
$query = "select * from ArticleLive_pages WHERE AuthorID = 3
order by PageID desc limit 1 ";
$results=mysql_query($query) or die (mysql_error());
while ($rows=mysql_fetch_array($results)) {
extract ($rows);
echo stripslashes("<font face=arial size=2>$Title");
echo " <a href='http://www.mysite.com/news2.php?PageID=$rows[PageID]'>";
echo "<font color=#800000>(more)</font>";
echo "</a>";
echo "<br>";
echo "<img src='http://www.mysite.com/articlelive/page_images/$a' border=0>";
}
?>
What's odd is that if I echo "$Image" the full array displays, so I know I am getting the data out of the db. But when I go to "explode" it, I can't seem to get the data to do anything. If I do a simple "echo $a" or "echo $b", nothing.
Is there something glaring that I am overlooking?>
THNKSSS!