-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample14.php
More file actions
33 lines (23 loc) · 732 Bytes
/
Copy pathsample14.php
File metadata and controls
33 lines (23 loc) · 732 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
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body>
<?php
try{
$dbh = new PDO('mysql:dbname=mydb;host=localhost;port=8888;charset=utf8','root','root');
$sql = 'SELECT * fROM items';
$stmt = $dbh->query($sql);
$sqls = "INSERT INTO items (id, name) VALUES (1000, '練習データ')";
$stmt-> execute();
foreach($records as $i){
echo $i['id'];
}
}catch(PDOException $e){
echo 'DB接続エラー:'.$e->getMessage();
}
?>
</body>
</html>