关于debian:“升级到php-7后调用未定义的函数mysql_connect()”

“Call to undefined function mysql_connect()” after upgrade to php-7

本问题已经有最佳答案,请猛点这里访问。

在我将php5升级到php7之后,我得到一个错误500

PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect()

我把这个放进我的APT来源,以便现在获得PHP7:

deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

我主要做的是:

1
2
apt-get remove php5
apt-get install php7-*

我用的是Debian Jessie的最新版本。

但我还是明白。这里有很多问题,所以我肯定都查过了。但我还没找到答案。


Warning This extension was deprecated in PHP 5.5.0, and it was removed
in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be
used. See also MySQL: choosing an API guide. Alternatives to this function include:

1
2
3
mysqli_connect()

PDO::__construct()

使用MySQLiPDO

1
2
<?php
$con = mysqli_connect('localhost', 'username', 'password', 'database');

读这个