I'm running a small rPi server (Apache2, php5 installed), and I was doing some research on how to display data onto a webpage from a SQL data base. So, thorough phpMyAdmin, I created a small database called "Test" using phpMyAdmin, and it has two columns (Name, Age), and three rows. I followed an tutorial on how to connect to it, and created these two files. However, I keep getting my "die" message of "Error connecting to database". Any help on what I might have done wrong would be appreciated! Feel free to request any additional details.
connect.php
$dbcon = mysqli_connect(DB_HOST, DB_USER, DB_PSWD, DB_NAME); //Connect
if(!$dbcon) {
die('Error connecting to database');
}
echo 'You have Connected Successfully';
?>
chonline.php
<?php
include ('connect.php');
$test = $dbcon;
echo $test;
?>
index.html
<html><body><h1>Raspberry Pi Test Page!</h1>
<p>If you see this message,rPi server is up and running.</p>
<p>Server Public IP: 67.164.104.19.</p>
</body>
<a href = "test.php">TableTest</a>
<a href = "chonline.php">Connection Successful?</a>
</html>
DB_HOST, DB_USER, DB_PSWD, DB_NAMEvalues ?mysqli_connect_error()- also, shouldn't you uselocalhostas database host, I'm assuming the MySQL server is running on the rPi?