My website reads a mySQL database and populates a form with all the data. One of the fields is populated with a DATETIME. If the user is new, their guideUpdated is null. When I make changes to the form and click save, it populates the guideUpdated field in the database to ‘0000-00-00 00:00:00’. I’m trying to fix this so if I leave the guideUpdated field empty on my form, then a NULL value goes into the database when the save button is clicked and an update is made. Here is the code I have right before the update is made:
if ($guideUpdated == “0000-00-00 00:00:00” || $guideUpdated == “”) {
$guideUpdated = null;
}
However, this still doesn’t work. Even though $guideUpdated is blank on the form, it still adds all of the zeros. Can someone point out what I’m missing here?
Thanks!