Fatal error: Call to undefined function mysql_connect()(致命错误:调用未定义函数 mysql_connect())
问题描述
我已经设置了 PHP、MySQL 和 Apache.localhost() 用于 PHP,它运行良好.但是在我下载 MySQL 之后,它会报告:
I have set up PHP, MySQL, and Apache. localhost() for PHP and it is working well. But after I downloaded MySQL, it reports:
致命错误:调用未定义函数 mysql_connect()
Fatal error: Call to undefined function mysql_connect()
我该如何解决这个问题?
How can I fix this?
推荐答案
您升级到 PHP 7,现在 mysql_connect 已弃用.检查你的:
You upgraded to PHP 7, and now mysql_connect is deprecated. Check yours with:
php -version
将其更改为 mysqli_connect 如下:
$host = "127.0.0.1";
$username = "root";
$pass = "foobar";
$con = mysqli_connect($host, $username, $pass, "your_database");
如果您要升级旧版 PHP,现在您面临的任务是使用 mysqli_* 函数升级所有 mysql_* 函数.
If you're upgrading legacy PHP, now you're faced with the task of upgrading all your mysql_* functions with mysqli_* functions.
这篇关于致命错误:调用未定义函数 mysql_connect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:致命错误:调用未定义函数 mysql_connect()
基础教程推荐
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
