TapeGun007 Posted August 18, 2011 Share Posted August 18, 2011 I posted in here, because I know the SQL is correct. When I do this in phpMyAdmin, this works great: Update Leads SET FollowUpDate='2011-08-18' WHERE FollowUpDate<'2011-08-18' But in PHP I have the code written (and I've tried several different ways): $TodaysDate = date("Y.m.d"); $statement="Update Leads SET FollowUpDate='$TodaysDate' WHERE FollowUpDate<'$TodaysDate'"; When I execute the SQL above, it actually resets all the dates to 0000-00-00... ug. What is the correct syntax? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/245125-php-mysql-syntax-problem/ Share on other sites More sharing options...
TeNDoLLA Posted August 18, 2011 Share Posted August 18, 2011 This $TodaysDate = date("Y.m.d"); should probably be $TodaysDate = date("Y-m-d"); so the date will be in the correct format (YYYY-MM-DD, not YYYY.MM.DD) for the mysql field. Quote Link to comment https://forums.phpfreaks.com/topic/245125-php-mysql-syntax-problem/#findComment-1259051 Share on other sites More sharing options...
TapeGun007 Posted August 18, 2011 Author Share Posted August 18, 2011 Yes, you are correct. However, now it simply does not update anything. Also, I did a echo $statement; And I get this: Update Leads SET FollowUpDate='2011-08-18' WHERE FollowUpDate<'2011-08-18' I purposely changed one date in phpMyAdmin to 2011-08-17, and it's not updating that record to 2011-08-18. Yet that nearly same command works fine in the SQL area of phpMyAdmin. So I am confused, must be improper syntax. Quote Link to comment https://forums.phpfreaks.com/topic/245125-php-mysql-syntax-problem/#findComment-1259054 Share on other sites More sharing options...
PFMaBiSmAd Posted August 18, 2011 Share Posted August 18, 2011 Are you actually executing the query in your php code? Do you have any error checking and error reporting logic in your php code that would tell you if and why the query is failing? Quote Link to comment https://forums.phpfreaks.com/topic/245125-php-mysql-syntax-problem/#findComment-1259057 Share on other sites More sharing options...
TapeGun007 Posted August 18, 2011 Author Share Posted August 18, 2011 I had remarked the execution out to back track and forgot to put it back in. It works now. My bad. Quote Link to comment https://forums.phpfreaks.com/topic/245125-php-mysql-syntax-problem/#findComment-1259062 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.