itgranny Posted February 13, 2014 Share Posted February 13, 2014 I'm sure the answer to this is out there but I have no idea what to call it. I've been googling most of the day trying to figure out different solutions. I have a supervisor visit form where I had been just time stamping with the current date. There's been times when the supervisor doesn't fill it out until the next day and I've got to figure out how to put a date in. It doesn't need to be a date that needs to be worked with I just want it to get put into the mysql table in anyway I can get it. What I've done is I've set up some dropdown forms they can put the date in. Now I'm trying to get the database to update. When I echo $visitDate, it displays it properly but it won't insert it correctly into the database. I've tried all sorts of things but none work. - seems to make it subtract, / makes it divide. I've tried making the mysql visitDate text and varchar but it still does math. $visitDate=$_POST[month] . "/" . $_POST[day] . "/" . $_POST[year]; Can someone spot what I'm doing wrong? thanks! Quote Link to comment Share on other sites More sharing options...
.josh Posted February 13, 2014 Share Posted February 13, 2014 what is the column type you are putting this in? Quote Link to comment Share on other sites More sharing options...
rythemton Posted February 14, 2014 Share Posted February 14, 2014 If you are inserting into a date column, MySQL expects a YYYY-MM-DD format. For a datetime column, YYYY-MM-DD HH:MM:SS. Quote Link to comment Share on other sites More sharing options...
Barand Posted February 14, 2014 Share Posted February 14, 2014 $visitDate = "{$_POST['year']}-{$_POST['month']}-{$_POST['day']}"; Then put the date variable in quotes in your query $sql = "INSERT INTO mytable(visitdate) VALUES ('$visitDate')"; Quote Link to comment 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.