Re: [PHP-DB] Corn job anomaly
[email protected] (Karl DeSaulniers) Tue, 27 Sep 2016 02:37:44 -0500
| Newsgroups | php.db |
|---|---|
| Message-ID | <[email protected]> |
> On Sep 27, 2016, at 2:24 AM, Ford, Mike <[email protected]> = wrote: >=20 >> -----Original Message----- >> From: Karl DeSaulniers [mailto:[email protected]] >> Sent: 25 September 2016 09:59 >> To: PHP List Database <[email protected]> >> Subject: Re: [PHP-DB] Corn job anomaly >>=20 >> Now I am getting an error with mysql syntax. >>=20 >> "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN = ".FIELDS_TABLE." cf >> ON cf.Order_ID =3D otn.Order_ID WHERE cf.Earliest_Pickup >=3D = DATE(NOW()) AND >> cf.Earliest_Pickup <=3D DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." = DAY) AND >> otn.Order_Status !=3D 'Shipping' AND otn.Order_Status !=3D = 'Completed'" >>=20 >> 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 !=3D \"Completed\"' at line 1 >=20 > I don't think INTERVAL works like that - you probably need something = like: >=20 > ... cf.Earliest_Pickup <=3D DATE_ADD(CURDATE(), INTERVAL = ".($Num_Days_Away+1)." DAY) AND ... >=20 > Incidentally, as I understand it CURDATE() does exactly the same as = DATE(NOW()), and is probably more readable. >=20 > Cheers! >=20 > Mike >=20 > -- > Mike Ford, Hi Mike, I figured out what was wrong with my script on that error.=20 I had mysqli_real_escape_string() wrapping the whole select statement.=20= 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=