I've got a rather simple script here that I can't get to work:
<?php
$host='localhost';
$user='root';
$passwd='password';
$db='cherry_pie';
echo 'Accessing database...<br/>';
$mysql_conn = new mysqli($host, $user, $passwd, $db);
if($mysql_conn->connect_error) die($mysql_conn->connect_error);
?>
The result in my browser is simply:
Accessing database...
Furthermore, no change in the web page occured after transposing
if($mysql_conn->connect_error) die($mysql_conn->connect_error);
with
print_r($mysql_conn);
which leaves me to believe that $mysql_conn is never being created.
I'm currently running ubuntu 16.04 and I've already run
sudo apt install php-mysql
sudo apt install mysql-server
sudo apt install mysql-client
Furthermore, I've run mysql through the shell and can verify that the database 'cherry_pie' does indeed exist.
Obviously my apache2 server is up and running and I already have other html documents and php scripts that will run properly.
I've already spent hours searching the php and mysql documentation, and I've referred to several other posts on this site to no avail, so any help will be greatly appreciated.
EDIT
I've also tried using mysqli_connect() which did not work.
Here's what my error log has to say:
[Fri Jun 23 13:10:38.214070 2017] [:error] [pid 12584] [client 127.0.0.1:56418] PHP Fatal error: Uncaught Error: Class 'mysqli' not found in /var/www/html/php_test.php:8\nStack trace:\n#0 {main}\n thrown in /var/www/html/php_test.php on line 8, referer: http://localhost/