RE: [PHP-DB] Corn job anomaly

2016-09-27 Thread Ford, Mike
> -Original Message-
> From: Karl DeSaulniers [mailto:k...@designdrumm.com]
> Sent: 25 September 2016 09:59
> To: PHP List Database 
> 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,
Electronic Information Developer, Libraries and Learning Innovation,
110 Queen Square House, 80 Woodhouse Lane,
Leeds Beckett University, Leeds LS2 8NU,  United Kingdom
E & S4B: m.f...@leedsbeckett.ac.uk T: +44 113 812 4730

To view the terms under which this email is distributed, please go to:-
http://disclaimer.leedsbeckett.ac.uk/disclaimer/disclaimer.html

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-27 Thread Karl DeSaulniers
> On Sep 27, 2016, at 2:24 AM, Ford, Mike  wrote:
> 
>> -Original Message-
>> From: Karl DeSaulniers [mailto:k...@designdrumm.com]
>> Sent: 25 September 2016 09:59
>> To: PHP List Database 
>> 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