PHP gd extension problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
DarkConsultant
Forum Newbie
Posts: 17
Joined: Mon Apr 14, 2008 3:17 am
Location: Luton, England

PHP gd extension problem

Post by DarkConsultant »

Hello Everyone,

I am running Apache 2.2.4 with PHP 5.2.3 on Windows 2000 and I cannot enable the gd extension. I get no errors but it just does not work. If I check phpinfo then I see everything else but no gd. PHP is working fine apart from the gd.

Any thoughts ...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: PHP gd extension problem

Post by Chris Corbyn »

How are you enabling it? Sorry, might be an patronising question.

Also... very imporant... and the cause of much furstration... don't forget the restart the httpd server.
User avatar
DarkConsultant
Forum Newbie
Posts: 17
Joined: Mon Apr 14, 2008 3:17 am
Location: Luton, England

Re: PHP gd extension problem

Post by DarkConsultant »

Hi everyone,

I have done all the usual things ....

In the PHPO ini file I have set the extensions directory, uncommented the gd2 dll and set the root directory.

I did google the problem but after spending 4 hours I was no closer so I have put it back to fresh install.

Does anyone have any suggestions ....
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: PHP gd extension problem

Post by onion2k »

Are you definitely editing the right php.ini file? php_info() will tell you which one PHP is using.
User avatar
DarkConsultant
Forum Newbie
Posts: 17
Joined: Mon Apr 14, 2008 3:17 am
Location: Luton, England

Re: PHP gd extension problem

Post by DarkConsultant »

Hi,

My php resides in a folder called C:\php5 and the ini file is in the same folder.

If I deliberately set a false reading php wont open so I think its the right one.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: PHP gd extension problem

Post by onion2k »

Ok. Save this little script into a file and run it from a browser...

Code: Select all

<?php
 
$i = imagecreate(200,200);
$red = imagecolorallocate($i,255,0,0);
imagefill($i,0,0,$red);
 
header("Content-type: image/jpeg");
imagejpeg($i);
 
Do you get a big red square?
User avatar
DarkConsultant
Forum Newbie
Posts: 17
Joined: Mon Apr 14, 2008 3:17 am
Location: Luton, England

Re: PHP gd extension problem

Post by DarkConsultant »

Hi,

No I got

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /home/val3072/public_html/test.php:6) in /home/val3072/public_html/test.php on line 10
ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀÈÈ"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?â袊ù“÷¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(ÿÙ
or see result for your self at http://www.contactconsultants.co.uk/test.php.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: PHP gd extension problem

Post by Chris Corbyn »

Looks like GD is installed to me ;) Even if there is an error in the code you've run. That warning is unrelated to GD, and the gibberish is image data.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: PHP gd extension problem

Post by Chris Corbyn »

It looks like you've wrapped that code inside a HTML document? That won't work, which is why there's a headers-sent warning appearing.
User avatar
DarkConsultant
Forum Newbie
Posts: 17
Joined: Mon Apr 14, 2008 3:17 am
Location: Luton, England

Re: PHP gd extension problem

Post by DarkConsultant »

Hi,

Now I remove the html I see a big red square ..... however this is on my remote server which has got gd installed successfully.

On my own server I get ...

Fatal error: Call to undefined function imagecreate() in F:\Webs\root\test.php on line 2.

Shall I give up and live without it?
User avatar
DarkConsultant
Forum Newbie
Posts: 17
Joined: Mon Apr 14, 2008 3:17 am
Location: Luton, England

Re: PHP gd extension problem

Post by DarkConsultant »

Additional ...

I have just noticed that when I look at phpinfo it report my Configuration File (php.ini) Path is C:\WINNT when it should be C:\php5 and it says below that Loaded Configuration File (none) although Under Apache Environment it reports PHPRC = C:/php5 (forward slash?).

I do not know if this is important or not.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: PHP gd extension problem

Post by onion2k »

It is important. For some reason your PHP installation is using the windows directory php.ini file instead of the php5 install directory version (I think.. I suck at sys admin stuff). You've got two options ... either attempt to make PHP use the right one ( http://uk.php.net/configuration ) or just update the one in the c:/winnt directory to enable GD like you did with the c:/php5 version. Updating the c:/winnt version is going to be the easier fix.
User avatar
DarkConsultant
Forum Newbie
Posts: 17
Joined: Mon Apr 14, 2008 3:17 am
Location: Luton, England

PHP gd extension problem (RESOLVED)

Post by DarkConsultant »

Hi All,

To all contributers ....

The problem is fixed by dropping a copy of php.ini into C:\WINNT et voila. (Although I will try to reconfigure it to use the c:\php5 version)

Many thanks to all.
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: PHP gd extension problem

Post by EverLearning »

For Apache2 there is PHPIniDir directive which tells the server where to look for php.ini.
User avatar
DarkConsultant
Forum Newbie
Posts: 17
Joined: Mon Apr 14, 2008 3:17 am
Location: Luton, England

PHP gd extension problem (RESOLVED)

Post by DarkConsultant »

Dear Everlearning,

Yah I know but it gets ignored. This was set to C:\php5 from the word go.

The solution .....

I promised to try and make it work (without resorting to dropping copy of php.ini into C:\WINNT) and I have found the solution.

In the Apache httpd.conf file amend PHPinidir path from 'C:\php5' to (wait for it) 'C:/php5' and the problem goes away.

Thanks again for all the help, I have put the instructions on how to (definitively) set up Apache 2.2.4 with PHP 5.2.3 on my website for general viewing. 8O
Post Reply