Jump to content

Archived

This topic is now archived and is closed to further replies.

kevdoug

displaying image using url stored in database

Recommended Posts

Hi I fairly new to PHP and what I am trying to achieve is to retrieve an image stored on the server using the url I have stored in the database. I can retrieve the url from the database and display it in text form but I am struggling to diplay the image. I have the code I am using below.

$img = OCIResult($stmt,'IMAGE');
     
      echo $img; this will display the text e.g. C:\winter.jpg
     
echo "<img src= "$img"\" >"; This is how I am trying to display the image
     

Share this post


Link to post
Share on other sites
Try this:
[code]echo "<img src=' " . $img . "' >";[/code]
You needed ' ' around the image source and .'s to get out of the "" and use the variable. instead of $img.

Share this post


Link to post
Share on other sites
your a *star* worked first time you would know how many hours ive spent on this.

Cheers

Share this post


Link to post
Share on other sites
No problem.  You might want to read up some more on single and double quotes.  I know they drive me insane as I can NEVER keep them straight.  It's hard to remember which does what with variables and escapes and all that.

Share this post


Link to post
Share on other sites
Hi ChaosXero

You couldn't tell me how to reduce the size of the image aswell as it has come out huge!

Share this post


Link to post
Share on other sites
Just edit the echo so that it contains an image size:
[code]echo "<img src=' " . $img . "' height='200' width='200'>";[/code] 

you could change those to variables too if you wanted to.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.