johnfoster Posted June 24, 2011 Share Posted June 24, 2011 Ok I'm having an issue with a simple PHP Inlcude that I've never ran in to before. Maybe you guys can help. I'm trying to include a picture simply titled 'promo1.jpg'.. I go about the normal PHP include way with this code: <?php include $_SERVER['DOCUMENT_ROOT'] . '/images/promo1.jpg'; ?> This proceeds to only output a question mark '?'. No error message. Nothing else. Just the server saying "What the hell?". I've tried not doing the DOCUMENT_ROOT route and tried more locally but still same '?'. Any ideas on this one? Any help is appreciated, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/240270-problem-with-php-include-outputs-a/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 24, 2011 Share Posted June 24, 2011 Images (all media files) on a web page are fetched by the browser using a URL to that image/media. You cannot include an actual image into a web page. You must use a HTML <img> tag in the markup of the page that lists the URL where the actual image can be fetched at - http://w3schools.com/html/html_images.asp Quote Link to comment https://forums.phpfreaks.com/topic/240270-problem-with-php-include-outputs-a/#findComment-1234132 Share on other sites More sharing options...
johnfoster Posted June 24, 2011 Author Share Posted June 24, 2011 Duuuh, how could I have forgotten! thanks for the help! I simply just included a piece of code with a div that had the background set to the image I was trying to use.. thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/240270-problem-with-php-include-outputs-a/#findComment-1234137 Share on other sites More sharing options...
colap Posted June 24, 2011 Share Posted June 24, 2011 Ok I'm having an issue with a simple PHP Inlcude that I've never ran in to before. Maybe you guys can help. I'm trying to include a picture simply titled 'promo1.jpg'.. I go about the normal PHP include way with this code: <?php include $_SERVER['DOCUMENT_ROOT'] . '/images/promo1.jpg'; ?> This proceeds to only output a question mark '?'. No error message. Nothing else. Just the server saying "What the hell?". I've tried not doing the DOCUMENT_ROOT route and tried more locally but still same '?'. Any ideas on this one? Any help is appreciated, thanks. You can't include an image. You have to echo image inside a html image tag. That was simple. Quote Link to comment https://forums.phpfreaks.com/topic/240270-problem-with-php-include-outputs-a/#findComment-1234314 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.