-1

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.

Eugeny89
  • 3,797
  • 7
  • 51
  • 98

2 Answers2

3

Call to undefined function mysql_connect

The mysql_ library was deprecated years ago. It has been removed entirely in PHP 7.

Use a modern replacement such as PDO or mysqli_.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
2

You need to use the mysqli_* functions, not mysql_*.

Thomas
  • 537
  • 1
  • 4
  • 14