Error in the SQL syntax - How do I solve this specific error?

I'm running a script that causes an SQL syntax error. However I am not good at MySQL at all, so I have no clue how to solve it.

Error:
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 a.merchant_id = 3 order by c.set_date' at line 1

The sql:
$sql = "select a.*,c.id as launched_id, b.subject, b.add_unsub_link, b.message, b.mail_type, d.subs_name, d.subs_email, d.id as subs_id, d.php_sess_id, b.id as message_id  from ".$CONFIG_TABLE_PREFIX."_auto_campaign_tb a,".$CONFIG_TABLE_PREFIX."_auto_messages_tb b,".$CONFIG_TABLE_PREFIX."_auto_launched_tb c,".$CONFIG_TABLE_PREFIX."_auto_subscribers_tb d where a.id = b.campaign_id and b.id = c.message_id and d.id = c.subscriber_id and c.set_date <='".date("Y-m-d H:i:s")."' and a.status = 1 and b.status = 1 and d.status = 1 and c.launched_status = -1 and d.validate = and a.merchant_id = ".$_SESSION["sess_ecommerce_merchant_id"]." order by c.set_date";

The database version is 5.0.67 community

Php version 5.2.6

Any else you need to point me in the right direction, or is it obvious what is wrong?


Here's the complete error message when running the file in my browser (FF3.0.6):

select a.*,c.id as launched_id, b.subject, b.add_unsub_link, b.message, b.mail_type, d.subs_name, d.subs_email, d.id as subs_id, d.php_sess_id, b.id as message_id from sc__auto_campaign_tb a,sc__auto_messages_tb b,sc__auto_launched_tb c,sc__auto_subscribers_tb d where a.id = b.campaign_id and b.id = c.message_id and d.id = c.subscriber_id and c.set_date <='2009-02-22 20:48:00' and a.status = 1 and b.status = 1 and d.status = 1 and c.launched_status = -1 and d.validate = and a.merchant_id = 3 order by c.set_dateYou 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 a.merchant_id = 3 order by c.set_date' at line 1
MaxresponsAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what I mean is: there is no value specified for the condition:



 and d.validate = <some value> <<<< this part is missing
 and a.merchant_id = <some value>
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you have this:

 and d.validate = and a.merchant_id

you are obviously missing the part to fill in the date...
0
 
MaxresponsAuthor Commented:
Hmm..

d.validate : "d" is a table called "auto_subscribers_tb" - and "validate" is a field in there...

Where does the date come in?
0
Network Scalability - Handle Complex Environments

Monitor your entire network from a single platform. Free 30 Day Trial Now!

 
MaxresponsAuthor Commented:
My bad.

Should be d.validate =1 and etc.

Let me try. Got Mysql syntax error before too. I'll try fix this obviuos error first :-)
0
 
MaxresponsAuthor Commented:
Yes, this is the correct sql (last part of it):
and d.validate = 1 and a.merchant_id = ".$_SESSION["sess_ecommerce_merchant_id"]." order by c.set_date";

:-)

I've been fighting some other errors the last days, and actually I made this error myself :-(

When I run the php file no ther's no error... :-)

Thanks for pointing this out for my tired eyes,,, I thought this had to do with me upgrading to MySql 5.. LOL
0
 
MaxresponsAuthor Commented:
Hi. Thanks for helping! - I had a huger sql error earlier, and I had just made my own error in the fix. But was so tired I couldn't see it ;-)  - Thanks again!
0
 
MaxresponsAuthor Commented:
I have asked the mods to upgrade the grade to an A. (I had misunderstood the A, B, C rating )

:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.