Jump to content

Problem with PHP Include. Outputs a "?".


johnfoster

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/240270-problem-with-php-include-outputs-a/
Share on other sites

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

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.

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.