简体   繁体   中英

PHP Fatal error : Call to undefined function mysql_connect()

I have recently installed PHP 7.0.8 (ZTS) on CentOS 7 with the following configuration:

--prefix=/usr/local/php7 \
--with-config-file-scan-dir=/usr/local/php7/etc/conf.d \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-opcache
--enable-dba \
--enable-ftp \
--with-gettext \
--with-gd \
--with-jpeg-dir \
--enable-mbstring \
--with-mcrypt \
--with-mhash \
--enable-mysqlnd \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysql-sock=/var/run/mysqld/mysqld.sock \
--with-openssl \
--enable-pcntl \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-zlib \
--enable-zip \
--with-readline \
--with-curl \
--enable-shmop \
--enable-fpm \
--enable-maintainer-zts \
--enable-pthreads=shared \
--with-tsrm-pthreads \
--enable-fastcgi \
--with-fpm-user=www-data \
 --with-fpm-group=www-data"

I can't go on my website because I have the following nginx log error when I try to go on my website:

[error] 20609#20609: *8 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /adodb/drivers/adodb-mysql.inc.php:461

This website is ok on an another server configured with Debian8, PHP7 (same configuration like here).

I have installed MySQL 5.7 and Nginx 1.10. How I can correct this error?

To correct the error, you've basically got two choices, either

1) modify the code to remove references to the mysql extension (and use mysqli or PDO instead), or

2) install an older version of PHP (before PHP7) which supports the mysql extension


FOLLOWUP:

If what you claim is true... that mysql_ functions are working under PHP7, then the most likely explanation for that is that someone installed a third party module/library that exports mysql_ functions.

I believe there was some work done to build such a library, to provide backwards compatiblity. The library would interact with the database using using the newer PHP mysqli_ functions, and provide (mostly) compatible mysql_ functions for legacy applications.

But that's not part of PHP7. That would be a third party add on.

PHP 7 has removed mysql_* completely. Use PDO or mysqli

The mysql_connect function was deprecated in version 5.5 and completely removed in 7.0.

You'll need to use mysqli or PDO.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM