note 79916 deleted from function.require by nlopess

From: Date: Wed, 19 Dec 2007 18:24:55 +0000
Subject: note 79916 deleted from function.require by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133785@lists.php.net to get a copy of this message
Note Submitter: m4u at centos dot mau4 ---- 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?

« previous php.notes (#133785) next »