[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-db
Subject:    Re: [PHP-DB] Corn job anomaly
From:       Karl DeSaulniers <karl () designdrumm ! com>
Date:       2016-09-27 7:37:44
Message-ID: ADE944F9-01D0-45F6-9F67-8B2E6EE938CF () designdrumm ! com
[Download RAW message or body]

> On Sep 27, 2016, at 2:24 AM, Ford, Mike <M.Ford@leedsbeckett.ac.uk> wrote:
> 
> > -----Original Message-----
> > From: Karl DeSaulniers [mailto:karl@designdrumm.com]
> > Sent: 25 September 2016 09:59
> > To: PHP List Database <php-db@lists.php.net>
> > Subject: Re: [PHP-DB] Corn job anomaly
> > 
> > Now I am getting an error with mysql syntax.
> > 
> > "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN ".FIELDS_TABLE." cf
> > ON cf.Order_ID = otn.Order_ID WHERE cf.Earliest_Pickup >= DATE(NOW()) AND
> > cf.Earliest_Pickup <= DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND
> > otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'"
> > 
> > is giving me this 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
> > '\"Shipping\" AND otn.Order_Status != \"Completed\"' at line 1
> 
> I don't think INTERVAL works like that - you probably need something like:
> 
> ... cf.Earliest_Pickup <= DATE_ADD(CURDATE(), INTERVAL ".($Num_Days_Away+1)." DAY) \
> AND ... 
> Incidentally, as I understand it CURDATE() does exactly the same as DATE(NOW()), \
> and is probably more readable. 
> Cheers!
> 
> Mike
> 
> --
> Mike Ford,


Hi Mike,
I figured out what was wrong with my script on that error. 
I had mysqli_real_escape_string() wrapping the whole select statement. 
The INTERVAL part I got from PHP.net and it is working just fine. Just fyi.
Once I wrapped just ($Num_Days_Away+1) part it started working.

Thanks for responding!

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic