Jump to content


Photo

Error inserting data into db via form


  • Please log in to reply
2 replies to this topic

#1 benjamin_boothe

benjamin_boothe
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 22 August 2006 - 07:36 PM

This is the error I am getting:

Error inserting data - Incorrect date value: '' for column 'date_of_birth' at row 1 with query INSERT INTO policy_holder (id, title, first_name, surname, date_of_birth, uk_residency, marital_status, disability, employment_status, address_line_1, area, town, county, post_code, telephone_work, telephone_home, fax_number, email) VALUES ( NULL, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')


I have used NULL as my id (auto_increment) value as this worked when I inserted a record via SQL command line client.

I have used DATE as my character type 'Foramt: YYYY-MM-DD', which I have used.  I cant see where the error is.

Can somebody please help!!!
 

#2 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 22 August 2006 - 07:39 PM

Try this:
INSERT INTO policy_holder (id, title, first_name, surname, date_of_birth, uk_residency, marital_status, disability, employment_status, address_line_1, area, town, county, post_code, telephone_work, telephone_home, fax_number, email) VALUES ( NULL, '', '', '', '', NOW(), '', '', '', '', '', '', '', '', '', '', '', '')
I'm not 100% sure but I don't think you can have an empty field that has a date/time datatype.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#3 benjamin_boothe

benjamin_boothe
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 22 August 2006 - 09:01 PM

Thankyou very much BUT...

It does add records to the db but, all the entries have come up as NULL barring the date_of_birth field that prints today's date.  I want it to print the date that I put into the form.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users