php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29033 GD had problems with "include" keyword
Submitted: 2004-07-06 17:34 UTC Modified: 2004-07-06 20:25 UTC
From: robotech at mixmail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4CVS-2004-07-06 (stable) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: robotech at mixmail dot com
New email:
PHP Version: OS:

 

 [2004-07-06 17:34 UTC] robotech at mixmail dot com
Description:
------------
I'm using GD to generate a dinamic image showing a chart.
It sees that there's and error when I try to use the keyword "include". 
I also try to use an empty file using the keyword "include" and the result it's the same.

Reproduce code:
---------------
/*************/
/* chart.php */
/*************/
Header ("Contect-type: image/jpeg");
include ("function.phtml"); //only a group of functions. They all work.
$imgW = 500; $imgH = 312;
$img = ImageCreate($imgW,$imgH);
$black = ImageColorAllocate($img,0,0,0);
$white = ImageColorAllocate($img,255,255,255);
ImageFilledRectangle($img,0,0,$imgW,$imgH,$white);
$font = 2;
$txt = "Hello, dude!";
ImageString($img,$font,100,100,$txt,$black);
ImageJPEG($img);
ImageDestroy($img);


Expected result:
----------------
If would like to reuse a same code inside function.phtml in all my dinamic charts.

Actual result:
--------------
It isn't working. Only works when I exclude the include.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-06 20:25 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

You probably have trailing or tailing whitespace in the include file.
 [2012-02-19 12:11 UTC] goshawngo at hotmail dot com
In response to derek,

i have tried using include or require and they both keep breaking my page and it says "The image cannot be displayed because it contains errors."

Is there anyway to use include?

Here is my code

<?php
header("Content-type: image/jpg");
include "psnvars.php";
$string = "email@example.com";
$font  = 4;
$width  = ImageFontWidth($font) * strlen($string);
$height = ImageFontHeight($font);
$im = @imagecreatetruecolor ($width,$height);
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 255, 255, 255);
imagestring ($im, $font, 0, 0,  $string, $text_color);
imagejpeg ($im);
?>

If i remove include "psnvars.php"; it starts working again
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 13:01:30 2024 UTC