Jump to content

displaying an image using php within the img src


barrowvian

Recommended Posts

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

 

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"

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.

Archived

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

×
×
  • Create New...

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.