quot;Call to undefined function mysql_connect()quot; after upgrade to php-7(“调用未定义函数 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()
使用 MySQLi
或 PDO
<?php
$con = mysqli_connect('localhost', 'username', 'password', 'database');
这篇关于“调用未定义函数 mysql_connect()"升级到 php-7 后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“调用未定义函数 mysql_connect()"升级到 php-7 后


- SoapClient 设置自定义 HTTP Header 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- Laravel 仓库 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01