SQLSTATE[42000]: Syntax error or access violation (please help)

Discussion in 'PHP' started by FutureKing, May 9, 2011.

  1. #1
    I am using zend framework.
    ------------------------------------

    $stmt = $this->getAdapter()->query("SELECT `tagjoins`.*, `tags`.`tag_name` FROM `tagjoins`
    INNER JOIN `tags` ON tags.tag_id = tagjoins.tag_id WHERE tagjoins.bmk_id = '12'");
    $r = $this->fetchAll($stmt);

    Above statement gives me this error:

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

    If I run above sql statement directly in mysql via SqlYog client. it works fine
     
    FutureKing, May 9, 2011 IP
  2. JoelLarson

    JoelLarson Peon

    Messages:
    61
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Make sure that the user you're connecting to your MySQL database with has privileges to do SELECT statements with JOIN and WHERE.
     
    JoelLarson, May 13, 2011 IP