From e975293caba8d28ed649d76c84863c4aaa67c460 Mon Sep 17 00:00:00 2001 From: William Miceli Date: Mon, 25 Nov 2019 06:06:27 -0500 Subject: [PATCH] Lots and lots of stuff... --- var/www/phptest.php | 80 ++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/var/www/phptest.php b/var/www/phptest.php index 4ba50ac..7a3066f 100644 --- a/var/www/phptest.php +++ b/var/www/phptest.php @@ -1,13 +1,10 @@ @@ -15,35 +12,52 @@ $user = "William"; // Testing with until we have login working

PHP Test Page

- -

Connecting to MySQL

+

MySQL

+ +

Creating Connection

setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - echo "Connected successfully"; - } - 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"; - } - - $conn = null; + 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".PHP_EOL; + } + catch(PDOException $e){ + echo "Connection failed: ".$e->getMessage().PHP_EOL; + } ?> -

PHP Session Info

+

Creating and Executing Query

query($sql) as $row){ + print $row['messageID']."\t"; + print $row['date']."\t"; + print $row['message']."\t"; + } + } + catch(Exception $e){ + echo "Error: ".$e->getMessage().PHP_EOL; + } + ?> +

$sql

+ "; + print_r($sql); + echo ""; + ?> + +

$_SESSION

+ "; + print_r($_SESSION); + echo ""; ?> - \ No newline at end of file + + + \ No newline at end of file