“调用未定义函数 mysql_connect()"升级到 php-7 后 [英] "Call to undefined function mysql_connect()" after upgrade to php-7

查看:30
本文介绍了“调用未定义函数 mysql_connect()"升级到 php-7 后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

php5 升级到 php7 后,我收到错误 500

After I upgraded php5 to php7, I get an error 500 with

PHP 致命错误:未捕获错误:调用未定义函数 mysql_connect()

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

我把它放到我的 apt 资源中,以便立即获得 php7:

I put this into my apt sources in order to get php7 right now:

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

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

我基本上做的是:

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

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

但我仍然明白这一点.这里有很多关于 SO 的问题,我肯定都检查过了.但我还没有找到答案.

But I still get this. There are a lot of questions here on SO and I definitely checked them all out. But I didn't find an answer there yet.

推荐答案

来自 PHP手册:

警告 此扩展在 PHP 5.5.0 中已弃用,并已被删除在 PHP 7.0.0 中.相反,MySQLi 或 PDO_MySQL 扩展名应该是用过的.另请参阅 MySQL:选择 API 指南.此功能的替代方案包括:

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()

使用 MySQLiPDO

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

这篇关于“调用未定义函数 mysql_connect()"升级到 php-7 后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆