Jump to content

php_gd2.dll doesn't work?


1337Reloaded

Recommended Posts

Im still learning PHP by reading a PHP & MySQL book and its talking about generating images. So i typed the code that it gives but every time i try to open the web page it gives me this error.

 

Warning: Cannot modify header information - headers already sent by (output started at C:\PHP Practice\xampp\htdocs\simplegraph.php:7) in C:\PHP Practice\xampp\htdocs\simplegraph.php on line 21

‰PNG ��� IHDR���È���È���":9É��ÚIDATxœíÝYrâ0EáÕë¬l X°z•Ü°:–Ù°ú–Ö°º—Ó°F”а•Í°Æ•Ê°†–Ç°F—Ä°&”Á°æÞ°¦Û°fØ°&Õ°æÒ°LÏ°¬Ì°É°lÆ°Ìð,À°ŒæÝ°ìæÚ°Lç×°¬çÔ°äÑ°|äΰÜäË°<åÈ°œåÅ°üå°\fß°¼fÜ°gÙ°|gÖ°ÜgÓ°"dÐÖMú;ûv{¬Ûí£p|ÉÈ-˧s·k5M…³fjrÇgçôY CegMü3û�J[]½6ŸßkoüÙ×qÑÃÖôÓ±ëùæ[ÍÑÙ%ro|ÝRë"¶ìÂÒR+^Ï;m¯ùaT=šnË4¬G¿/0¯ÔJxmŽY} K³mÙ…µ7)“µ7>êRøl¢-ß»Â+«¡‘ÝSïfíí~¥‚ÝÜë;r5}%»¿ØKákã¯[¦aQÃÛò½Ryƒ×D`%j¤-`åj˜-`¥kŒ-`el€-`%­·-`å­«-`¥®Ÿ-`e¯“-`Q[À"©ƒ-`ÑWmm‹¾khXô£V¶€EëšØmtÝ°h»‹¶€E»]±,zWµ-`ÑAu¶€EÇUØuÖ°¨´S¶€E'*·,:W¡-`ÑéJl‹j:´,ªì½-`Q}ol‹.µgXtµM[À¢ý¶,jÓÊ°¨Y¯¶€E-ûþÛ~ƒ”š·,Ÿÿ�xwÀKPK����IEND®B`‚

 

<html>
<head>
<title>Simple Graph</title>
</head>

<body>
<?php
// Set up image
$height = 200;
$width = 200;
$im = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($im, 255, 255, 255);
$blue = imagecolorallocate($im, 0, 0, 64);

// Draw on image
imagefill($im, 0, 0, $blue);
imageline($im, 0, 0, $width, $height, $white);
imagestring($im, 4, 50, 150, 'Sales', $white);

// Output image
header('Content-type: image/png');
imagepng($im);

// Clean up
imagedestroy ($im);
?>
</body>

</html>

Link to comment
Share on other sites

You're simply outputting the page as a png image. This means, any text that is not png data (That isn't in code) will result in an error, as your HTML code is not png data.

 

Simply remove all output other than the PHP code, and do not echo/print anything and it should work. For your header error, It means it cannot send the header telling the browser it is a png image, because you already outtputted something (HTML).

 

That's why you get the error and the erroneous data.

Link to comment
Share on other sites

You're simply outputting the page as a png image. This means, any text that is not png data (That isn't in code) will result in an error, as your HTML code is not png data.

 

Simply remove all output other than the PHP code, and do not echo/print anything and it should work. For your header error, It means it cannot send the header telling the browser it is a png image, because you already outtputted something (HTML).

 

That's why you get the error and the erroneous data.

Wow thank you soo much!!! Most people in coding forums usually don't answer my questions so thanks a loT!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.