-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.php
35 lines (25 loc) · 923 Bytes
/
data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
function debug_to_console( $data ) {
$output = $data;
if ( is_array( $output ) )
$output = implode( ',', $output);
echo "<script>console.log( 'Debug Objects: " . $output . "' );</script>";
}
require_once 'dbconfig.php';
$dsn = "pgsql:host=$host;dbname=$db;user=$username;password=$password";
try{
$conn = new PDO($dsn);
if ($conn){
//debug_to_console("Connected to the database successfully!");
$stmt = $conn->prepare('SELECT * FROM xp WHERE id = ?');
$id = "botstats";
$stmt->execute([$id]);
$result = $stmt->fetch();
// $result = $conn->query("SELECT * FROM xp WHERE id = 'botstats'");
echo json_encode($result);
}
}catch (PDOException $e){
echo $e->getMessage();
}
//debug_to_console("Test");
?>