I have ran aptitude install php5-mysql
(and restarted MySQL/Apache 2), but I am still getting this error:
Fatal error: Call to undefined
If someone came here with the problem of docker php official images, type below command inside the docker container.
$ docker-php-ext-install mysql mysqli pdo pdo_mysql
For more information, please refer to the link above How to install more PHP extensions
section(But it's a bit difficult for me...).
Or this doc may help you.
https://docs.docker.com/samples/library/php/
I was also stuck with the same problem of undefined MySQL_connect().I tried to make changes in PHP.ini file but it was giving me the same error. Then I came to this solution where I changed my code from depreciated php functions to new functions.
$con=mysqli_connect($host,$user,$password);
mysqli_select_db($con,dbname);
//To select the database
session_start(); //To start the session
$query=mysqli_query($con,your query);
//made query after establishing connection with database.
I hope this will help you . This solution is correctly working for me .
EDIT:
If you upgrade form old php you need to apt-get install php7.0-mysql