数据库
首页 > 数据库> > “升级到php-7后调用未定义的函数mysql_connect()”

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

作者:互联网

参见英文答案 > Why shouldn’t I use mysql_* functions in PHP?                                    15个
在我将php5升级到php7后,我收到错误500

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

为了获得php7,我把它放到我的apt源码中:

deb 07001 jessie all
deb-src 07001 jessie all

我基本上做的是:

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

我正在使用当前版本的Debian Jessie.

但我仍然得到这个.这里有很多关于SO的问题我绝对检查过它们.但我还没有找到答案.

解决方法:

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:

mysqli_connect()

PDO::__construct()

使用MySQLi或PDO

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

Read this

标签:php,debian,php-7
来源: https://codeday.me/bug/20190916/1807340.html