-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbaccess.php
48 lines (35 loc) · 1013 Bytes
/
dbaccess.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
35
36
37
38
39
40
41
42
43
44
45
46
<?php
$dsn = 'mysql:host=database-yinwenyi-1.crqmemsomjjy.ap-northeast-1.rds.amazonaws.com;dbname=web_log';
$username = 'web_user';
$password = '!QAZ1qaz';
// try-catch
try{
$pdo = new PDO($dsn,$username,$password);
$sql = "select created_at, info from site_view_history order by created_at desc limit 1";
$stmt = $pdo->prepare($sql);
$stmt -> execute();
$rec = $stmt->fetch(PDO::FETCH_ASSOC);
$sqlins = "insert into site_view_history (info) values ('insert test from " . exec(hostname) . "')";
$stmtins = $pdo->prepare($sqlins);
$stmtins -> execute();
}catch (PDOException $e) {
}
function escape1($str)
{
return htmlspecialchars($str,ENT_QUOTES,'UTF-8');
}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>test page for database access</title>
</head>
<body >
Last Access Time<br><br>
<?php foreach ($rec as $a):?>
<?=escape1($a)?><br>
<?php endforeach; ?>
Auto Scale Test 191212
</body>
</html>