troubleshooting Question

Date of birth insertion insertion in mysql through php.

Avatar of Souvik Misra
Souvik Misra asked on
HTMLPHP* datetimeMySQL Server
20 Comments1 Solution265 ViewsLast Modified:
I am having a problem while inserting the Date of Birth field's value from html form to mysql datebase using the php. I have used the input type 'date' in html to get the input.
      $DOB = explode("/",$DOB);
      $DOB = "$DOB[2]-$DOB[0]-$DOB[1]";
      $sql = "INSERT INTO signin (F_name,U_name,password,email,DOB,phn)VALUES ('$F_name','$U_name','$password','$email','$DOB','$phn')";
DOB:<input type="date" name="DOB" size="20"><br><br>

output error:
( ! ) Notice: Undefined offset: 2 in C:\wamp64\www\Blogger\signin.php on line 20
Call Stack
#      Time      Memory      Function      Location
1      0.0004      248128      {main}( )      ...\signin.php:0

( ! ) Notice: Undefined offset: 1 in C:\wamp64\www\Blogger\signin.php on line 20
Call Stack
#      Time      Memory      Function      Location
1      0.0004      248128      {main}( )      ...\signin.php:0
Error: INSERT INTO signin (F_name,U_name,password,email,DOB,phn)VALUES ('kkkk','qqqqq','77777','mmmmmmmmm','/2017-03-24/','10000000')
Incorrect date value: '/2017-03-24/' for column 'DOB' at row 1
mohan singh
Web developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 20 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 20 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros