jakebur01 Posted July 8, 2011 Share Posted July 8, 2011 How can I insert a date if it doesn't have a value. MySQL column is formatted as date. I am getting an error while inserting. Not all of the rows have dates. $ASSIGNED_DATE=$row['ASSIGNED_DATE']; $OPENED_DATE=$row['OPENED_DATE']; $LAST_SALE_DATE=$row['LAST_SALE_DATE']; $LAST_PMT_DATE=$row['LAST_PMT_DATE']; $HIGH_BAL_DATE=$row['HIGH_BAL_DATE']; Link to comment https://forums.phpfreaks.com/topic/241436-inserting-date-with-no-value/ Share on other sites More sharing options...
jakebur01 Posted July 8, 2011 Author Share Posted July 8, 2011 MySQL ERROR: Incorrect date value: '' for column 'OPENED_DATE' at row 1 Link to comment https://forums.phpfreaks.com/topic/241436-inserting-date-with-no-value/#findComment-1240215 Share on other sites More sharing options...
Zane Posted July 8, 2011 Share Posted July 8, 2011 I am getting an error while inserting. It sure would be neat, not to mention, helpful if you told us what the error message says. EDIT: ok, I see it now. Link to comment https://forums.phpfreaks.com/topic/241436-inserting-date-with-no-value/#findComment-1240216 Share on other sites More sharing options...
jakebur01 Posted July 8, 2011 Author Share Posted July 8, 2011 MySQL ERROR: Incorrect date value: '' for column 'OPENED_DATE' at row 1 The columns are set to allow null. Jake Link to comment https://forums.phpfreaks.com/topic/241436-inserting-date-with-no-value/#findComment-1240217 Share on other sites More sharing options...
Zane Posted July 8, 2011 Share Posted July 8, 2011 what does echoing $OPENED_DATE show? Link to comment https://forums.phpfreaks.com/topic/241436-inserting-date-with-no-value/#findComment-1240218 Share on other sites More sharing options...
jakebur01 Posted July 8, 2011 Author Share Posted July 8, 2011 Opened date is the second one. This is an echo of part of the query. '2003-11-14', '', '2011-06-28', '2011-06-30', '2010-03-11', '5169' Opened date is '' Link to comment https://forums.phpfreaks.com/topic/241436-inserting-date-with-no-value/#findComment-1240220 Share on other sites More sharing options...
Zane Posted July 8, 2011 Share Posted July 8, 2011 How can I insert a date if it doesn't have a value MySQL ERROR: Incorrect date value: '' for column 'OPENED_DATE' at row 1 The columns are set to allow null. Opened date is the second one. '2003-11-14', '', '2011-06-28', '2011-06-30', '2010-03-11', '5169' The column is set to allow NULL values, not blank ones.. your query needs to look like this... well at least the snippet you provided does. '2003-11-14', NULL, '2011-06-28', '2011-06-30', '2010-03-11', '5169' Notice how NULL has no quotes around it. I also believe you could get away with nothing there at all, but I'm not sure. '2003-11-14', , '2011-06-28', '2011-06-30', '2010-03-11', '5169' Link to comment https://forums.phpfreaks.com/topic/241436-inserting-date-with-no-value/#findComment-1240233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.