zh3n Posted September 20, 2007 Share Posted September 20, 2007 Hello. I am trying to use the ImageCreate() function to create some graphs on a website. It's not working. I was wondering if anyone could help me figure out why this wouldnt work? I am using this test code: <?php $im = @ ImageCreate ( 150, 100) or die ( "Cannot create a new GD image."); $background_color = ImageColorAllocate ($im, 255, 255, 255); $text_color = ImageColorAllocate ($im, 233, 14, 91); ImageString ($im, 1, 5, 5, "A Simple Text String", $text_color ); header ("Content-type: image/png"); ImagePng ($im); ?> It works on my personal server, but it does not work on my client's server. (which i do not have admin access to, and the server admin does not want to help me out) Error messages are turned off, so I don't know exactly whats happening. It doesn't display an image on the page, just the URL of the php file the code was in. Also, as the page title, it says "info.php (Image)". It should say "info.php (PNG Image, 150x100 pixels)" The server admin tells me PHP and GD are installed and according to phpinfo(): PHP Version 4.4.2 Apache Version Apache/2.0.48 (Unix) mod_fastcgi/2.4.2 PHP/4.4.2 mod_ssl/2.0.48 OpenSSL/0.9.6b GD Support enabled GD Version bundled (2.0.28 compatible) Could anybody help me out here and give me some advice on what is going wrong? Does apache have to be configured correctly to allow PNG extensions or something? Thanks a bunch!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/69984-solved-need-help-getting-imagecreate-to-work/ Share on other sites More sharing options...
trq Posted September 20, 2007 Share Posted September 20, 2007 Error messages are turned off So turn them on.... <?php error_reporting(E_ALL) ; ini_set('display_errors','1'); $im = ImageCreate(150, 100); $background_color = ImageColorAllocate ($im, 255, 255, 255); $text_color = ImageColorAllocate ($im, 233, 14, 91); ImageString ($im, 1, 5, 5, "A Simple Text String", $text_color ); header ("Content-type: image/png"); ImagePng ($im); ?> Quote Link to comment https://forums.phpfreaks.com/topic/69984-solved-need-help-getting-imagecreate-to-work/#findComment-351512 Share on other sites More sharing options...
zh3n Posted September 20, 2007 Author Share Posted September 20, 2007 Ah thanks. I tried it again and got: <b>Fatal error</b>: imagepng(): gd-png: fatal libpng error: Incompatible libpng version in application and library in <b>/domains/HaysGroundwater/welldata/info.php</b> on line <b>11</b><br /> But the good news is that I switched it out with gif instead of png and the code seems to work ok now. Thanks d00d! Quote Link to comment https://forums.phpfreaks.com/topic/69984-solved-need-help-getting-imagecreate-to-work/#findComment-351549 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.