質問編集履歴
2
エラー内容
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,9 +48,11 @@
|
|
48
48
|
|
49
49
|
$idx = 0;
|
50
50
|
|
51
|
+
$sql = '';
|
52
|
+
|
51
53
|
while ($idx < count($arr)) {
|
52
54
|
|
53
|
-
$sql ='INSERT INTO テーブル名 (id,word) VALUES (NULL,$arr[$idx])';
|
55
|
+
$sql .='INSERT INTO テーブル名 (id,word) VALUES (NULL,$arr[$idx])';
|
54
56
|
|
55
57
|
$stmt = $pdo->prepare($sql);
|
56
58
|
|
@@ -72,6 +74,18 @@
|
|
72
74
|
|
73
75
|
```
|
74
76
|
|
77
|
+
エラー内容
|
78
|
+
|
79
|
+
sqlError:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[$idx])' at line 1
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
75
89
|
### 補足情報(FW/ツールのバージョンなど)
|
76
90
|
|
77
91
|
|
1
検索ワードの追記、コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,19 +34,41 @@
|
|
34
34
|
|
35
35
|
```php
|
36
36
|
|
37
|
+
try {
|
38
|
+
|
39
|
+
$pdo = new PDO($dbn, $user, $pwd);
|
40
|
+
|
41
|
+
} catch (PDOException $e) {
|
42
|
+
|
43
|
+
exit('dbError:'.$e->getMessage());
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
|
37
49
|
$idx = 0;
|
38
50
|
|
39
|
-
while ($idx < count($arr
|
51
|
+
while ($idx < count($arr)) {
|
40
52
|
|
41
|
-
$sql ='INSERT INTO テーブル名(id,
|
53
|
+
$sql ='INSERT INTO テーブル名 (id,word) VALUES (NULL,$arr[$idx])';
|
54
|
+
|
55
|
+
$stmt = $pdo->prepare($sql);
|
56
|
+
|
57
|
+
$status = $stmt->execute();
|
42
58
|
|
43
59
|
$idx = $idx + 1;
|
44
60
|
|
45
|
-
}
|
46
61
|
|
47
|
-
$stmt = $pdo->prepare($sql);
|
48
62
|
|
63
|
+
if ($status==false) {
|
64
|
+
|
49
|
-
$
|
65
|
+
$error = $stmt->errorInfo();
|
66
|
+
|
67
|
+
exit('sqlError:'.$error[2]);
|
68
|
+
|
69
|
+
} else {
|
70
|
+
|
71
|
+
header('Location: index.php');
|
50
72
|
|
51
73
|
```
|
52
74
|
|
@@ -54,4 +76,4 @@
|
|
54
76
|
|
55
77
|
|
56
78
|
|
57
|
-
超基礎的ですいません、
|
79
|
+
超基礎的ですいません、「mysql php 配列」といったワードで検索しましたがよくわからず…
|