PHP Fatal error : Call to undefined function mysql_connect()

爱⌒轻易说出口 提交于 2021-01-29 18:02:11

问题


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?


回答1:


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.




回答2:


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




回答3:


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

You'll need to use mysqli or PDO.



来源:https://stackoverflow.com/questions/38441178/php-fatal-error-call-to-undefined-function-mysql-connect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!