tags:

views:

46

answers:

2

Hello All, I am having an issue with a simple insert query into a table.

I have this PHP Code

$T_MEMBER = "INSERT INTO T_MEMBER (MEMBER_IDENTIFIER,LAST_NAME,FIRST_NAME,BIRTH_DATE) VALUES ('$memberID','$last','$first','$birthdate')";
mysql_query($T_MEMBER) or die(mysql_error());    

Here are a few examples of what the query looks like if i echo it:

INSERT INTO T_MEMBER (MEMBER_IDENTIFIER,LAST_NAME,FIRST_NAME,BIRTH_DATE) VALUES ('2007','Hayes','Karin','1958-30-10') INSERT INTO T_MEMBER (MEMBER_IDENTIFIER,LAST_NAME,FIRST_NAME,BIRTH_DATE) VALUES ('2020','Long','Peggy','1968-29-5') INSERT INTO T_MEMBER (MEMBER_IDENTIFIER,LAST_NAME,FIRST_NAME,BIRTH_DATE) VALUES ('2021','Torres','Diane','1968-30-8')

BIRTH_DATE is a date type column.

The problem is, after i do any of these queries, the date shows up as 000-00-00!!!! I have been wracking my brain and i cannot seem to find the issue.

Thanks, Ian

+2  A: 

The date needs to be in YYYY-MM-DD format. Yours is in YYYY-DD-M(thanks juliano) format by the way.

So instead of 1958-29-05, use 1968-05-29

Sev
In fact, his date format is YYYY-DD-M
Juliano
A: 

You might also want to consider passing in the date as a variable, and first formatting it using mktime() and date().

joshv2