barrowvian Posted March 30, 2010 Share Posted March 30, 2010 I am wanting to dynamically display an image. So far I have got; <img style="border: 1px black solid" alt="Photo gallery" src="<?php $image_path . "profile.jpg"; ?>" id="tempGallery" width="160" height="160"> with $image_path being the directory which is called from a cookie. I could not include profile.jpg within the cookie as I use that for other parts of the site. All Im wanting to do is display the profile image, but I do need the $image_path in there also. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/196979-displaying-an-image-using-php-within-the-img-src/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 30, 2010 Share Posted March 30, 2010 Php code must echo things in order to cause them to be output to the browser. <?php $image_path . "profile.jpg"; ?> outputs nothing (do a 'view source' in your browser to see what you are getting.) <?php echo $image_path . "profile.jpg"; ?> will output whatever is in $image_path concatenated with "profile.jpg" Quote Link to comment https://forums.phpfreaks.com/topic/196979-displaying-an-image-using-php-within-the-img-src/#findComment-1034086 Share on other sites More sharing options...
barrowvian Posted March 30, 2010 Author Share Posted March 30, 2010 ok Ive just given that a go but still nothing, it just displays the border of the image with the alt "photo gallery" inside. Ive checked the source and the dir is fine but still its not outputting the image properly :-\ Quote Link to comment https://forums.phpfreaks.com/topic/196979-displaying-an-image-using-php-within-the-img-src/#findComment-1034090 Share on other sites More sharing options...
PFMaBiSmAd Posted March 30, 2010 Share Posted March 30, 2010 Then the path must be incorrect relative to the page that the code is on or the image by that exact name and letter-case (assuming you are on an operating system that is case sensitive) does not exist and the problem is not really a php problem anymore. Quote Link to comment https://forums.phpfreaks.com/topic/196979-displaying-an-image-using-php-within-the-img-src/#findComment-1034093 Share on other sites More sharing options...
barrowvian Posted March 30, 2010 Author Share Posted March 30, 2010 Just deleted this message.........cause I found the mistake. My bad ha. Problem fixed though. Quote Link to comment https://forums.phpfreaks.com/topic/196979-displaying-an-image-using-php-within-the-img-src/#findComment-1034096 Share on other sites More sharing options...
litebearer Posted March 30, 2010 Share Posted March 30, 2010 Just a thought ... does $image_path contain the trailing slash (/) ? For some unknown reason, the post of your code is not visible to me. Quote Link to comment https://forums.phpfreaks.com/topic/196979-displaying-an-image-using-php-within-the-img-src/#findComment-1034099 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.