2017-06-29 2 views
0

Hier ist meine Frage:Syntaxfehler oder Zugriffsverletzung

SELECT qa.id, 
     qa.subject, 
     qa.category cat, 
     qa.keywords tags, 
     qa.body_html, 
     qa.amount, 
     qa.author_id author, 
     qa.visibility, 
     qa.date_time, 
     COALESCE(u.reputation, 'N') reputation, 
     COALESCE(CONCAT(u.user_fname, ' ', u.user_lname), 'ناشناس') name, 
     COALESCE(u.avatar, 'anonymous.png') avatar, 

    (SELECT COALESCE(sum(vv.value),0) 
    FROM votes vv 
    WHERE qa.id = vv.post_id 
    AND 15 = vv.table_code) AS total_votes, 

    (SELECT COALESCE(sum(vt.total_viewed),0) 
    FROM viewed_total vt 
    WHERE qa.id = vt.post_id 
    AND 15 = vt.table_code 
    LIMIT 1) AS total_viewed 
FROM qanda qa 
INNER JOIN qanda_tags qt ON qt.qanda_id = qa.id 
INNER JOIN tags ON tags.id = qt.tag_id 
LEFT JOIN users u ON qa.author_id = u.id 
AND qa.visibility = 1 
WHERE qa.type = 0 tags.name = :t 
ORDER BY qa.date_time DESC 
LIMIT :j, 
     11; 

Und es wirft diesen Fehler:

Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'tags.name = ? ORDER BY qa.date_time desc LIMIT ?,11' at line 18 in C:\xampp\htdocs\myweb\others\questions.php:136 Stack trace: #0 C:\xampp\htdocs\myweb\others\questions.php(136): PDO->prepare('SELECT qa.id, q...') #1 C:\xampp\htdocs\myweb\others\questions.php(293): questions->index('tags.name = :t1', '\tINNER JOIN qan...') #2 C:\xampp\htdocs\myweb\application\other.php(21): questions->tagged() #3 C:\xampp\htdocs\myweb\index.php(149): require_once('C:\xampp\htdocs...') #4 {main} thrown in C:\xampp\htdocs\myweb\others\questions.php on line 136

Ich weiß nicht wirklich, was das Problem ist. Die Fehlermeldung sagt, es ist in der Nähe tags.name = ?, aber es ist völlig richtig für mich.

Hat jemand was ist das Problem?

Antwort

2

ersetzen

WHERE qa.type = 0 tags.name = :t 

mit

WHERE qa.type = 0 AND tags.name = :t 
+0

Guter Fang .. Warum ich das nicht gesehen haben. Trotzdem danke –

Verwandte Themen