469,353 Members | 2,050 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

PHP GD support problem

23
Hi! I am using php5 extracted from the zip package downloaded from php.net. I have already set the php_gd2.dll extension at the php.ini as well as the extension_dir. However, I still get error undefined function everytime I use a GD function. I read that I have to configure php with GD support. How to do that with php5. I have also downloaded the GD lib but don't know how or what to do to configure it. Please advies.

A novice PHP developer
Mar 4 '09 #1
19 3577
numberwhun
3,503 Expert Mod 2GB
@rsbgm

First, what OS are you on? (ie: Windows, Linux, etc). Second, you say you are getting errors. Can you please post them?

Regards,

Jeff
Mar 5 '09 #2
rsbgm
23
Hi Jeff,
I'm on Windows XP Pro. The error I get is:

Fatal error: Call to undefined function imagecreatetruecolor() in C:\Inetpub\wwwroot\MyWeb\image_test.php on line 2

The code is:

Expand|Select|Wrap|Line Numbers
  1. $im = imagecreatetruecolor(100, 100);
  2.  
  3. imagealphablending($im, true);
  4.  
  5. imagefilledrectangle($im, 30, 30, 70, 70, imagecolorallocate($im, 255, 0, 0));
  6.  
  7. header('Content-type: image/png');
  8.  
  9. imagepng($im);
  10. imagedestroy($im);
  11.  
I would get the same error on line 4, the next GD function. Hope you can help.

REY
Mar 5 '09 #3
Markus
6,050 Expert 4TB
Have you gone through all the steps here? Have you uncommented the gd extension line in the php.ini file?
but calling it without GD2 being installed PHP will issue a fatal error and exit.
Mar 5 '09 #4
rsbgm
23
Hi Markus,

Yes, sir, I did. I uncommented it. Even tried to put a tag [PHP_GD2] on the extension=php_gd2.dll like:

[PHP_GD2]
extension=php_gd2.dll

Still doesn't work. Still wont recognize GD functions. I really hope you can help resolve this.

REY
Mar 5 '09 #5
Markus
6,050 Expert 4TB
@rsbgm
And you have restarted the server?

Try creating a php file and inside write gd_info() then view the file's output (if any). What does that give you?
Mar 5 '09 #6
rsbgm
23
Hi Markus,

Yes, I've re-started the server. I just did your gd_info() test and got the same fatal error.

Fatal error: Call to undefined function gd_info() in C:\Inetpub\wwwroot\MyWeb\gd_info.php on line 2

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. gd_info();
  3. ?>
  4.  
For some reason, it's not detecting my php_gd2.dll on my extension folder.
Darn. What am I doing wrong?

REY
Mar 5 '09 #7
hoopy
88
Where do you have the php_gd2.dll file located?

Have a check of the file permissions for the dll as well make sure its readable, etc.
Mar 5 '09 #8
Markus
6,050 Expert 4TB
Does the gd2 dll exist in your ext (extension) directory? If you do a phpinfo() call on your page, what does your extension_dir show? Is that correct?

I don't know what you're doing wrong :P

I find silly little problems arise all the time, especially when I'm trying to configure a server. Some things work, some things just don't.

What are you using for a server? I recommend using EasyPHP or XAMP - they make dealing with the server very easy.
Mar 5 '09 #9
rsbgm
23
@hoopy

The php_gd2.dll is located in the ext folder. it's readable, in place, and set properly in my php.ini file. I got it working now though (see response below to Markus).

@markus

You were right about conflict of directories. Apparently, the config file is not loaded as indicated on phpinfo() and the extension_dir indicated there is c:\php5 while my php root dir is c:\php (without the 5). I have included c:\php (w/o the 5)on my PATH and the extension_dir inside php.ini is set to c:\php (w/o the 5). So, I wondered why.

I tried to change my php root dir and renamed it to c:\php5 which caused the browser not to find the module anymore. I returned it to c:\php (w/o the 5).

I realized that one of the ways the config file is searched is through the registry. So, I added a reg key for ... PHP/5/IniFilePath -> c:\php ... BINGO! It worked. My GD functions are now working. Thanks to all of you guys!!!

A NEW PROBLEM

A new problem arose though. Everytime I access phpinfo() or gd_info(), I get a blank page. Now, why is that?

REY
Mar 6 '09 #10
Markus
6,050 Expert 4TB
Wow! I'm very glad you got that working. We get that question a lot, and often times, I have no idea what the issue is, but now we have some more insight into the problem. So, a big thanks to you.

You know, I seem to get the same problem when using the gd_info() call. I get a blank screen. If I do a print_r(gd_info()) it shows me the output, but I thought gd_info was much like phpinfo() in the way that it gives you output automatically. I've never experienced that with phpinfo(), though.
Mar 6 '09 #11
rsbgm
23
Yes, the print_r(gd_info()) prints the corresponding output for me too. But, dang, that phpinfo() thing sucks. I am unable to to check on some needed info for debugging or whatever purposes.
Mar 6 '09 #12
hoopy
88
Is there no useful information in the error logs for PHP or IIS? Seems like IIS is just not displaying the error.
Mar 6 '09 #13
Markus
6,050 Expert 4TB
I imagine it's because you've changed the registry. Is this an IIS server? I'm doing some research now, I'll see what comes up. Don't hold your breath, though. :P
Mar 6 '09 #14
Markus
6,050 Expert 4TB
Can you access specific elements of the php_info, as outlined here? (also, did you try echo()ing phpinfo(), instead of just calling it?)

I'm scraping the walls for possibilities here.
Mar 6 '09 #15
rsbgm
23
@hoopy

Yes, it seems that IIS doesn't log errors. I'm not really sure about this too.

@markus

I couldn't access specific elements as outline in php.net. I tried it several times. As far as the registry is concerned, I only added a key. I did not change anything. But...... Alas! I somehow stumbled into a solution accidentally.

Now, I'm not sure if this provides good info for everyone. This is kinda embarrassing too. You may want to check it out on your side as well.

If I understand it correctly, the 'php' after the '<?' at the start of the code is not necessary. I guess not for all circumstances. For some reason, I saw that I am missing the 'php' after the '<?' on the phpinfo.php code to display the phpinfo(). I always place it as a good programming practice. And when I typed it back, everything is fine now. I can see the phpinfo() again. If I remove it, the page will display blank again. Hmmm...

Now, I am pretty certain that if I did miss placing that 'php', how was I able to access it before the resolution of the GD functions issue. I couldn't have accidentally erased it. It was just yesterday. Dang! Now, I wouldn't know. Hehe..

My bad!

Oh! The gd_info() is still blank. So, we are now on the same track. Hehe..
Mar 6 '09 #16
Markus
6,050 Expert 4TB
You don't need to use <?php if you have shorttags enabled (then you can just use <? - but most programmers are against using it).

After checking the documentation on gd_info(), it shows the it does in fact return an array. So you have to access it like an array (not like phpinfo()).

Glad you got everything working!
Mar 6 '09 #17
rsbgm
23
@markus

Thank you very much! Thanks for the gd_info() information. Now, I also understand.

@numberhwun
@hoopy

Thank you very much as well.

Thanks to every one and I hope that this thread can help others too.
Go, go, go, PHP addicts... :D

.
Mar 6 '09 #18
Markus
6,050 Expert 4TB
Glad we could all be of help :)
Mar 6 '09 #19
numberwhun
3,503 Expert Mod 2GB
@Markus
Agreed! :) .
Mar 7 '09 #20

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by shaun.mostashari | last post: by
5 posts views Thread by NormaJean Sebastian via DBMonster.com | last post: by
22 posts views Thread by Matthew Louden | last post: by
3 posts views Thread by Pramod TK | last post: by
2 posts views Thread by needin4mation | last post: by
14 posts views Thread by Anoop | last post: by
reply views Thread by Jack Wu | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.