views:

35

answers:

2

Hi,

I have this query, running from a PHP page:

       $feed_sql = "SELECT id, title, description, rssDate 
           FROM feed 
          WHERE MATCH (title) AGAINST ('" . $rows['suburb'] . "') 
            AND NOT EXISTS(SELECT feed_id, recipient_id, issent
                             FROM tracking_table
                            WHERE tracking_table.feed_id = $feed_id
                              AND tracking_table.recipient_id = $recipient_id
                              AND tracking_table.issent = 'Y')
       GROUP BY pubDate 
       ORDER BY pubDate DESC 
          LIMIT 1";

However, it returns the following errors upon running it:

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 tracking_table.recipient_id = AND tracki' at line 7

Line 7 being this:

  AND tracking_table.recipient_id = $recipient_id

Some server information:

PHP Version 5.2.6-1+lenny9
MySQL Version 5.0.51a

Thanks :-)

+2  A: 

As you can see here:

'AND tracking_table.recipient_id = AND tracki'
//       value missing here     --^

the value of $recipient_id seems to be empty and generates invalid syntax.

Felix Kling
was about to hit "Post Your Answer" too hehe
lock
A: 

Perhaps $recipient_id is an empty string. Please check it

jancrot