The @mysql_connect code to connect to the database was housed in an html file without Apache being configured to run html files as php files. I am managing to connect to the DB now only only with a .php format file. The final working code was:
$conn = mysqli_connect("localhost", "root", "password", "dbname");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
And it was saved in the web server as databaseConnection.php.
At that point, adding the correct parameters lead to a successful connection and adding incorrect parameters lead to an error message being displayed.