PHP GD support problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsbgm
    New Member
    • Mar 2009
    • 23

    PHP GD support problem

    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
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by rsbgm
    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

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

    Regards,

    Jeff

    Comment

    • rsbgm
      New Member
      • Mar 2009
      • 23

      #3
      @numberwhun

      Hi Jeff,
      I'm on Windows XP Pro. The error I get is:

      Fatal error: Call to undefined function imagecreatetrue color() in C:\Inetpub\wwwr oot\MyWeb\image _test.php on line 2

      The code is:

      Code:
      $im = imagecreatetruecolor(100, 100);
      
      imagealphablending($im, true);
      
      imagefilledrectangle($im, 30, 30, 70, 70, imagecolorallocate($im, 255, 0, 0));
      
      header('Content-type: image/png');
      
      imagepng($im);
      imagedestroy($im);
      I would get the same error on line 4, the next GD function. Hope you can help.

      REY
      Last edited by Markus; Mar 5 '09, 09:43 AM. Reason: Fixed [code] tags.

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Have you gone through all the steps here? Have you uncommented the gd extension line in the php.ini file?
        Originally posted by php.net
        but calling it without GD2 being installed PHP will issue a fatal error and exit.

        Comment

        • rsbgm
          New Member
          • Mar 2009
          • 23

          #5
          Hi Markus,

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

          [PHP_GD2]
          extension=php_g d2.dll

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

          REY

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            Originally posted by rsbgm
            Hi Markus,

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

            [PHP_GD2]
            extension=php_g d2.dll

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

            REY
            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?

            Comment

            • rsbgm
              New Member
              • Mar 2009
              • 23

              #7
              @markus

              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\wwwr oot\MyWeb\gd_in fo.php on line 2

              Code:
              <?php
              gd_info();
              ?>
              For some reason, it's not detecting my php_gd2.dll on my extension folder.
              Darn. What am I doing wrong?

              REY
              Last edited by numberwhun; Mar 5 '09, 02:03 PM. Reason: Please use code tags, not PHP

              Comment

              • hoopy
                New Member
                • Feb 2009
                • 88

                #8
                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.

                Comment

                • Markus
                  Recognized Expert Expert
                  • Jun 2007
                  • 6092

                  #9
                  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.

                  Comment

                  • rsbgm
                    New Member
                    • Mar 2009
                    • 23

                    #10
                    @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

                    Comment

                    • Markus
                      Recognized Expert Expert
                      • Jun 2007
                      • 6092

                      #11
                      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.

                      Comment

                      • rsbgm
                        New Member
                        • Mar 2009
                        • 23

                        #12
                        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.

                        Comment

                        • hoopy
                          New Member
                          • Feb 2009
                          • 88

                          #13
                          Is there no useful information in the error logs for PHP or IIS? Seems like IIS is just not displaying the error.

                          Comment

                          • Markus
                            Recognized Expert Expert
                            • Jun 2007
                            • 6092

                            #14
                            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

                            Comment

                            • Markus
                              Recognized Expert Expert
                              • Jun 2007
                              • 6092

                              #15
                              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.

                              Comment

                              Working...