teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

入力ミス

2016/12/25 16:00

投稿

space_sss
space_sss

スコア81

title CHANGED
File without changes
body CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  ```
12
12
  こちらで表示すると
13
- 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
13
+ 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
14
14
  39行目とは
15
15
  $stmt->execute($cont_box);
16
16
  こちらのと文となります。

2

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

2016/12/25 16:00

投稿

space_sss
space_sss

スコア81

title CHANGED
File without changes
body CHANGED
@@ -18,6 +18,16 @@
18
18
  php 5.6
19
19
  phpMyAdmin 5.6.23
20
20
  です。
21
+ ちなみにこちらですと問題なくエラーが出ませんので配列の受け渡しによりエラーが起きてるのかな?とは推測しております。
22
+ ```php
23
+ $cont=array(1,2,3,4,);//ここは常に変わる数値
24
+ $inClause = substr(str_repeat(',?', count($cont)), 1);
25
+ $sql='SELECT * FROM `table` WHERE `category` IN ('.$inClause.') ORDER BY `id` DESC limit 10 offset 5';
26
+ $stmt=$dbh->prepare($sql);
27
+ $stmt->execute($cont);
28
+
29
+ ```
30
+
21
31
  ご回答お待ちしております。
22
32
 
23
33
  さらにここで本来のリミットをかけない状態のヒットした数を数えたいので無理やりこれの前に

1

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

2016/12/25 15:46

投稿

space_sss
space_sss

スコア81

title CHANGED
File without changes
body CHANGED
@@ -9,7 +9,15 @@
9
9
  $stmt->execute($cont_box);//ここでエラー表示
10
10
 
11
11
  ```
12
+ こちらで表示すると
13
+ 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
14
+ 39行目とは
15
+ $stmt->execute($cont_box);
12
16
  こちらのと文となります。
17
+ 環境は
18
+ php 5.6
19
+ phpMyAdmin 5.6.23
20
+ です。
13
21
  ご回答お待ちしております。
14
22
 
15
23
  さらにここで本来のリミットをかけない状態のヒットした数を数えたいので無理やりこれの前に