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:

[Sun Mar 14 21:53:47 2010] [error] [client 192.168.1.101] 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:

[root@dev mm-forms]# yum install php-gd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: mirror.nexcess.net
 * base: mirrors.liquidweb.com
 * epel: ftp.osuosl.org
 * extras: mirror.steadfast.net
 * updates: updates.interworx.info
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-gd.x86_64 0:5.1.6-24.el5_4.5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================
 Package                     Arch                        Version                                 Repository                    Size
====================================================================================================================================
Installing:
 php-gd                      x86_64                      5.1.6-24.el5_4.5                        updates                      117 k

Transaction Summary
====================================================================================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 117 k
Is this ok [y/N]: y
Downloading Packages:
php-gd-5.1.6-24.el5_4.5.x86_64.rpm                                                                           | 117 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : php-gd                                                                                                       1/1

Installed:
  php-gd.x86_64 0:5.1.6-24.el5_4.5

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:

[root@dev ~]# /etc/init.d/httpd restart
Stopping httpd: [  OK  ]
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.


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


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

Share