federico Guastadisegni federico Guastadisegni - 1 year ago 57
HTML Question

Can't Load PHP in Apache

i have a database in phpmyadmin called "bddiscos", and I 'm trying to use the following code to make the connection:

$cnx = mysql_connect("localhost", "root", "root") or die("Error!");
$db = mysql_select_db("bddiscos");

What gives me the following error , according to the apache error.log:

[Fri Jul 08 12:46:23.533006 2016] [:error] [pid 6664] [client] PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect()

And I'm not sure why.

Answer Source

Seems like mysqlextension is not enabled in your server. On the other hand, mysql is deprecated now and you should not use it anymore on your projects. I would recommend you to use either PDO or mysqli.

In case still if you want to use mysql, run the following command:

sudo apt-get install libapache2-mod-auth-mysql php7.0-mysql

Then restart your Apache server,

sudo service apache2 restart
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download