0

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 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.