CentOS Linux: PHP Fatal error:  Call to undefined function imagetypes()

CentOS Linux: PHP Fatal error: Call to undefined function imagetypes()

After moving a WordPress site from one server to a brand new server I ran into an issue with one of the WordPress plugins called MM-Forms. The MM-Forms WordPress plugin allows you to easily create contact forms that will either email filled out forms to you, store those forms in the MySQL database, or both email you and store the results in the database. The issue was the fact that the contact form was not displaying on the page it was configured to display on. After digging around a bit I located the issue by looking in the Apache logs. The issue ended up being with the PHP function called imagetypes. Below I describe the actual error noticed in the Apache logs, the CentOS RPM package that will provide the PHP function that was missing, and the yum logs from installing the package.

CentOS Linux PHP imagetypes Error From Apache Error Logs:


  1. [Sun Mar 14 21:53:47 2010] [error] [client] PHP Fatal error:  Call to undefined function imagetypes() in /var/www/tools/wp-content/plugins/mm-forms/mm-forms.php on line 1281

As you can see above the issue with the MM-Forms plugin not displaying appears to be from an undefined PHP function called imagetypes. The imagetypes function is provided by the php-gd RPM package available from the default yum repositories on CentOS. Issue the below command to install php-gd on CentOS Linux using the yum package manager.

Install php-gd On CentOS Linux To Provide The imagetypes PHP Function:


  1. [root@dev mm-forms]# yum install php-gd
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4.  * addons: mirror.nexcess.net
  5.  * base: mirrors.liquidweb.com
  6.  * epel: ftp.osuosl.org
  7.  * extras: mirror.steadfast.net
  8.  * updates: updates.interworx.info
  9. Setting up Install Process
  10. Resolving Dependencies
  11. --> Running transaction check
  12. ---> Package php-gd.x86_64 0:5.1.6-24.el5_4.5 set to be updated
  13. --> Finished Dependency Resolution
  15. Dependencies Resolved
  17. ====================================================================================================================================
  18.  Package                     Arch                        Version                                 Repository                    Size
  19. ====================================================================================================================================
  20. Installing:
  21.  php-gd                      x86_64                      5.1.6-24.el5_4.5                        updates                      117 k
  23. Transaction Summary
  24. ====================================================================================================================================
  25. Install      1 Package(s)
  26. Update       0 Package(s)
  27. Remove       0 Package(s)
  29. Total download size: 117 k
  30. Is this ok [y/N]: y
  31. Downloading Packages:
  32. php-gd-5.1.6-24.el5_4.5.x86_64.rpm                                                                           | 117 kB     00:00
  33. Running rpm_check_debug
  34. Running Transaction Test
  35. Finished Transaction Test
  36. Transaction Test Succeeded
  37. Running Transaction
  38.   Installing     : php-gd                                                                                                       1/1
  40. Installed:
  41.   php-gd.x86_64 0:5.1.6-24.el5_4.5
  43. Complete!

Make sure after you install the php-gd package that you restart Apache as displayed in the below example for the new functions to be available to your PHP applications.

Restart Apache On CentOS Linux After php-gd Installed For imagetypes Function:


  1. [root@dev ~]# /etc/init.d/httpd restart
  2. Stopping httpd: [  OK  ]
  3. Starting httpd: [  OK  ]

After restarting Apache the contact forms started displaying properly and I no longer say any log messages relating to the MM-Forms plugin.

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems (Paperback)

List Price: $29.95 USD
New From: $1.93 USD In Stock
Used from: $0.01 USD In Stock

Learning PHP, MySQL, and JavaScript: A Step-By-Step Guide to Creating Dynamic Websites (Animal Guide) (Paperback)

List Price: $39.99
New From: $8.92 USD In Stock
Used from: $0.01 USD In Stock