PHP Fatal error: Call to undefined function mysql_connect()

En servidores linux cuando nos falta la librería de PHP para enlazar con las bases de datos MySQL nos devuelve el siguiente error:

PHP Fatal error:  Call to undefined function mysql_connect()


Para resolverlo tenemos que instalar la librería php-mysql, por ejemplo en CentOS lo podemos hacer con yum:

> yum install php-mysql
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: sunsite.rediris.es
 * extras: mir01.syntis.net
 * updates: mirror.in2p3.fr
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-mysql.i386 0:5.1.6-39.el5_8 set to be updated
--> Processing Dependency: php-pdo for package: php-mysql
--> Running transaction check
---> Package php-pdo.i386 0:5.1.6-39.el5_8 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                    Arch                  Version                          Repository             Size
===============================================================================================================
Installing:
 php-mysql                  i386                  5.1.6-39.el5_8                   base                   87 k
Installing for dependencies:
 php-pdo                    i386                  5.1.6-39.el5_8                   base                   66 k

Transaction Summary
===============================================================================================================
Install       2 Package(s)
Upgrade       0 Package(s)

Total download size: 153 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): php-pdo-5.1.6-39.el5_8.i386.rpm                                                  |  66 kB     00:03
(2/2): php-mysql-5.1.6-39.el5_8.i386.rpm                                                |  87 kB     00:00
---------------------------------------------------------------------------------------------------------------
Total                                                                           29 kB/s | 153 kB     00:05
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : php-pdo                                                                                 1/2
  Installing     : php-mysql                                                                               2/2

Installed:
  php-mysql.i386 0:5.1.6-39.el5_8

Dependency Installed:
  php-pdo.i386 0:5.1.6-39.el5_8

Complete!
You have new mail in /var/spool/mail/root




Leave a Reply

Your email address will not be published. Required fields are marked *