php7和mysql扩展

时间:2016-10-04 13:07:23

标签: php mysql

启动以下代码后......

<?php
error_reporting(E_ALL);
mysql_connect()
?>

我在日志中有Uncaught Error: Call to undefined function mysql_connect()

首先要记住的是sudo apt-get install php-mysql,但输出

Reading package lists... Done
Building dependency tree
Reading state information... Done
php-mysql is already the newest version

之后我做了dpkg --list | grep mysql并且说安装了php-mysqlphp7.0-mysql

这里有什么问题?

PS。 PHP版本为7.0.8

2 个答案:

答案 0 :(得分:3)

  

调用未定义的函数mysql_connect

多年前,mysql_库已被弃用。它已在PHP 7中完全删除。

使用现代替代品,例如PDO或mysqli_

答案 1 :(得分:2)

您需要使用mysqli_*个功能,而不是mysql_*