質問編集履歴

3

入力ミス

2016/12/25 16:00

投稿

space_sss
space_sss

スコア81

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  こちらで表示すると
24
24
 
25
- Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 ''0'' at line 1' in アドレス:39 Stack trace: #0 アドレス(39): PDOStatement->execute(Array) #1 {main} thrown in アドレス on line 39
25
+ Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 ''5'' at line 1' in アドレス:39 Stack trace: #0 アドレス(39): PDOStatement->execute(Array) #1 {main} thrown in アドレス on line 39
26
26
 
27
27
  39行目とは
28
28
 

2

エラーの表示されているところから自分の推測の文を追加いたしました。

2016/12/25 16:00

投稿

space_sss
space_sss

スコア81

test CHANGED
File without changes
test CHANGED
@@ -38,6 +38,26 @@
38
38
 
39
39
  です。
40
40
 
41
+ ちなみにこちらですと問題なくエラーが出ませんので配列の受け渡しによりエラーが起きてるのかな?とは推測しております。
42
+
43
+ ```php
44
+
45
+ $cont=array(1,2,3,4,);//ここは常に変わる数値
46
+
47
+ $inClause = substr(str_repeat(',?', count($cont)), 1);
48
+
49
+ $sql='SELECT * FROM `table` WHERE `category` IN ('.$inClause.') ORDER BY `id` DESC limit 10 offset 5';
50
+
51
+ $stmt=$dbh->prepare($sql);
52
+
53
+ $stmt->execute($cont);
54
+
55
+
56
+
57
+ ```
58
+
59
+
60
+
41
61
  ご回答お待ちしております。
42
62
 
43
63
 

1

修正内容を更新いたしました。

2016/12/25 15:46

投稿

space_sss
space_sss

スコア81

test CHANGED
File without changes
test CHANGED
@@ -20,7 +20,23 @@
20
20
 
21
21
  ```
22
22
 
23
+ こちらで表示すると
24
+
25
+ Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 ''0'' at line 1' in アドレス:39 Stack trace: #0 アドレス(39): PDOStatement->execute(Array) #1 {main} thrown in アドレス on line 39
26
+
27
+ 39行目とは
28
+
29
+ $stmt->execute($cont_box);
30
+
23
31
  こちらのと文となります。
32
+
33
+ 環境は
34
+
35
+ php 5.6
36
+
37
+ phpMyAdmin 5.6.23
38
+
39
+ です。
24
40
 
25
41
  ご回答お待ちしております。
26
42