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

2022-01-30 00:00:00 php mysql

我已经设置了 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.

相关文章