Jump to content


Photo

displaying image using url stored in database


  • Please log in to reply
6 replies to this topic

#1 kevdoug

kevdoug
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 20 July 2006 - 02:04 PM

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
     

#2 ChaosXero

ChaosXero
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts

Posted 20 July 2006 - 02:08 PM

Try this:
echo "<img src=' " . $img . "' >";
You needed ' ' around the image source and .'s to get out of the "" and use the variable. instead of $img.

#3 kevdoug

kevdoug
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 20 July 2006 - 02:13 PM

your a *star* worked first time you would know how many hours ive spent on this.

Cheers



#4 ChaosXero

ChaosXero
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts

Posted 20 July 2006 - 02:17 PM

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.

#5 kevdoug

kevdoug
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 20 July 2006 - 02:22 PM

Hi ChaosXero

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

#6 ChaosXero

ChaosXero
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts

Posted 20 July 2006 - 02:24 PM

Just edit the echo so that it contains an image size:
echo "<img src=' " . $img . "' height='200' width='200'>";
 

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

#7 kevdoug

kevdoug
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 20 July 2006 - 02:34 PM

Cheers I seem to be getting some where now.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users