kevdoug Posted July 20, 2006 Share Posted July 20, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/15145-displaying-image-using-url-stored-in-database/ Share on other sites More sharing options...
ChaosXero Posted July 20, 2006 Share Posted July 20, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15145-displaying-image-using-url-stored-in-database/#findComment-61014 Share on other sites More sharing options...
kevdoug Posted July 20, 2006 Author Share Posted July 20, 2006 your a *star* worked first time you would know how many hours ive spent on this.Cheers Quote Link to comment https://forums.phpfreaks.com/topic/15145-displaying-image-using-url-stored-in-database/#findComment-61015 Share on other sites More sharing options...
ChaosXero Posted July 20, 2006 Share Posted July 20, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15145-displaying-image-using-url-stored-in-database/#findComment-61018 Share on other sites More sharing options...
kevdoug Posted July 20, 2006 Author Share Posted July 20, 2006 Hi ChaosXeroYou couldn't tell me how to reduce the size of the image aswell as it has come out huge! Quote Link to comment https://forums.phpfreaks.com/topic/15145-displaying-image-using-url-stored-in-database/#findComment-61025 Share on other sites More sharing options...
ChaosXero Posted July 20, 2006 Share Posted July 20, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15145-displaying-image-using-url-stored-in-database/#findComment-61027 Share on other sites More sharing options...
kevdoug Posted July 20, 2006 Author Share Posted July 20, 2006 Cheers I seem to be getting some where now. Quote Link to comment https://forums.phpfreaks.com/topic/15145-displaying-image-using-url-stored-in-database/#findComment-61035 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.