forked from baraql/CS3083
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelloworld.php
More file actions
24 lines (21 loc) · 751 Bytes
/
helloworld.php
File metadata and controls
24 lines (21 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
try {
$conn = new PDO("mysql:host=localhost;dbname=criminalthing", "root");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully"; // Display message upon successful connection
} catch (PDOException $e) {
echo "Connection failed: " . $e->getMessage(); // Display error message if connection fails
}
$sql = "SELECT * FROM criminals";
$stmt = $conn->prepare($sql);
$stmt->execute();
echo 'Criminals information: <br />';
while ($row = $stmt->fetch()) {
echo '----------------------------------------<br />';
foreach ($row as $columnName => $columnValue) {
echo $columnName . ': ' . $columnValue . '<br />';
}
}
?>