Undefined function mysql_connect()
I see that you tagged this with Ubuntu. Most likely the MySQL driver (and possibly MySQL) is not installed. Assuming you have SSH or terminal access and sudo permissions, log into the server and run this:
sudo apt-get install mysql-server mysql-client php5-mysql
If the MySQL packages or the php5-mysql package are already installed, this will update them.
UPDATE
Since this answer still gets the occasional click I am going to update it to include PHP 7. PHP 7 requires a different package for MySQL so you will want to use a different argument for the apt-get command.
# Replace 7.4 with your version of PHP
sudo apt-get install mysql-server mysql-common php7.4 php7.4-mysql
And importantly, mysql_connect()
has been deprecated since PHP v5.5.0. Refer the official documentation here: PHP: mysql_connect()
Well, this is your chance! It looks like PDO is ready; use that instead.
Try checking to see if the PHP MySQL extension module is being loaded:
<?php
phpinfo();
?>
If it's not there, add the following to the php.ini
file:
extension=php_mysql.dll
In case, you are using PHP7 already, the formerly deprecated functions mysql_*
were removed entirely, so you should update your code using the PDO-functions or mysqli_*
functions instead.
If that's not possible, as a workaround, I created a small PHP include file, that recreates the old mysql_*
functions with mysqli_*()
-functions: fix_mysql.inc.php