note 79916 added to function.require
| From: | m4u at centos dot mau4 | Date: | Wed, 19 Dec 2007 17:39:41 +0000 |
| Subject: | note 79916 added to function.require | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-133783@lists.php.net to get a copy of this message | ||
I found a strange behavior with require/include when showing images (gif,jpeg) with header() - from
a blob/mysql or directly from a file.
When using require or include, like the following code:
require (".config.php");
$conexao=mysql_connect("localhost",$userdb,$passwddb);
$selecao=mysql_select_db($database,$conexao);
$sql = "select image FROM tb_img WHERE id= $_GET['id']";
$result = mysql_query("$sql") or die mysql_error();
mysql_fetch_array($result,MYSQL_NUM);
header("Content-Type: image/jpeg");
echo $res[0] ;
The image cannot be displayed and the error goes like: Error interpreting JPEG image file (Not a
JPEG file: starts with 0x20 0x0a)
The file .config.php is nothing but some declaration of variables inside the tags '<?'
'?>'.
Interestingly, when removing the line: require (".config.php"); and declaring variables
locally, the image is displayed ok.
I noticed that for some reason, 2 bytes are appended to the image when using require, messing up
with the browser interpretation of the image.
Any clues? Or is it a bug?
----
Server IP: 200.185.126.110
Probable Submitter: 200.198.55.3
----
Manual Page -- http://www.php.net/manual/en/function.require.php
Edit -- https://master.php.net/note/edit/79916
Del: integrated -- https://master.php.net/note/delete/79916/integrated
Del: useless -- https://master.php.net/note/delete/79916/useless
Del: bad code -- https://master.php.net/note/delete/79916/bad+code
Del: spam -- https://master.php.net/note/delete/79916/spam
Del: non-english -- https://master.php.net/note/delete/79916/non-english
Del: in docs -- https://master.php.net/note/delete/79916/in+docs
Del: other reasons-- https://master.php.net/note/delete/79916
Reject -- https://master.php.net/note/reject/79916
Search -- https://master.php.net/manage/user-notes.php