回答編集履歴
2
構文エラーに気づかず。。
answer
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
```
|
|
3
3
|
$sql = "INSERT INTO sample2 (name, old, sex, birthday, address, hobby, birthplace, job, favfood, favmovie
|
|
4
4
|
) VALUES
|
|
5
|
-
('$ans[0]',
|
|
5
|
+
('$ans[0]', $ans[1], '$ans[2]', '$ans[3]', '$ans[4]', '$ans[5]', '$ans[6]', '$ans[7]', '$ans[8]', '$ans[9]')";
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
|
|
@@ -10,13 +10,12 @@
|
|
|
10
10
|
```php
|
|
11
11
|
<?php
|
|
12
12
|
$sql = "INSERT INTO sample2 (name, old, sex, birthday, address, hobby, birthplace, job, favfood, favmovie) VALUES "
|
|
13
|
-
. "(:
|
|
13
|
+
. "(:name, :old, :sex, :birthday, :address, :hobby, :birthplace, :job, :favfood, :favmovie)";
|
|
14
14
|
|
|
15
15
|
$stmt = $pdo->prepare($sql);
|
|
16
16
|
|
|
17
|
-
$stmt->bindParam(':
|
|
17
|
+
$stmt->bindParam(':name', $ans[0], PDO::PARAM_STR);
|
|
18
|
-
$stmt->bindParam(':lastname', $ans[1], PDO::PARAM_STR);
|
|
19
|
-
$stmt->bindValue(':old', $ans[
|
|
18
|
+
$stmt->bindValue(':old', $ans[1], PDO::PARAM_INT);
|
|
20
19
|
.
|
|
21
20
|
.
|
|
22
21
|
.
|
1
文法修正
answer
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
$stmt = $pdo->prepare($sql);
|
|
16
16
|
|
|
17
17
|
$stmt->bindParam(':firstname', $ans[0], PDO::PARAM_STR);
|
|
18
|
-
$stmt->
|
|
18
|
+
$stmt->bindParam(':lastname', $ans[1], PDO::PARAM_STR);
|
|
19
19
|
$stmt->bindValue(':old', $ans[2], PDO::PARAM_INT);
|
|
20
20
|
.
|
|
21
21
|
.
|