After launching the following code...
<?php
error_reporting(E_ALL);
mysql_connect()
?>
I have Uncaught Error: Call to undefined function mysql_connect()
in log.
The first thing that comes in mind is to do sudo apt-get install php-mysql
but it outputs
Reading package lists... Done
Building dependency tree
Reading state information... Done
php-mysql is already the newest version
after that I did dpkg --list | grep mysql
and it said that php-mysql
and php7.0-mysql
are installed.
What is wrong here?
PS. PHP version is 7.0.8
.
You need to use the
mysqli_*
functions, notmysql_*
.The
mysql_
library was deprecated years ago. It has been removed entirely in PHP 7.Use a modern replacement such as PDO or
mysqli_
.