2011-07-08 6 views
-1

を問い合わせますこのエラー:致命的な問題は、私はこれらの3つのクエリに関する問題を抱えている

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 ') and 
test_history.user_id = 82' at line 3 

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 ') and 
test_history.user_id = 82 and is_correct = 1' at line 2 

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 ')' at line 1 

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 ') and percentage > 0' at 
line 3 
+0

{$ _SESSION ['history_ids']}にはどのような値がありますか?これが妥当な値 – wonk0

+0

がPHPコードとして表示されるように拡大してください。 – Subdigger

+0

はい、正常なユーザーIDを持っています。82 – Marco

答えて

2

$_SESSION['ids_tests']以降、配列であると思われます。implode(',',$_SESSION['ids_test'])と書く必要があります。 PHPの場合:

$query = "select * from test_topics inner join 
     test_topics_link on test_topics.`topic_id` = test_topics_link.`topic_id` 
     where test_topics_link.test_id in (". 
     implode(',',$_SESSION['ids_tests']).") and percentage > 0"; 
+0

これはすべてで動作しません。 – Marco

+0

「どこの列(...)」という構文を使用しているので、この構文が値リストで機能することを知っていると仮定しました。つまり、$ _SESSION ['ids_tests']が配列である限り、私が公開したコードが動作します。それ以外の場合は、その構文を使用せず、代わりに "where column = '...'"を使用してください。 –

関連する問題