diff --git a/var/www/phptest.php b/var/www/phptest.php
index cdf9f10..01d907d 100644
--- a/var/www/phptest.php
+++ b/var/www/phptest.php
@@ -1,38 +1,38 @@
connect_error) {
- die("Connection failed: " . $conn->connect_error);
-}
-echo "Connected successfully";
-
-?>
+// Current user
+$user = "William"; // Testing with until we have login working
- PHP connect to MySQL
+ PHP Test Page - Connecting to MySQL
';
+ try{
+ $connection = new PDO("mysql:host=$server;dbname=$database", $username, $password);
+ // set the PDO error mode to exception
+ $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ echo "Connected successfully";
}
- //Step 4
+ catch(PDOException $e){
+ echo "Connection failed: " . $e->getMessage();
+ }
+
+ $sql = "SELECT messageID, date, message
+ FROM messages
+ WHERE recipient=$user";
+ foreach($connection->query($sql) as $row){
+ print $row['messageID'] . "\t";
+ print $row['date'] . "\t";
+ print $row['message'] . "\t";
+ }
+
mysqli_close($db);
?>