Forum Moderators: coopster

Message Too Old, No Replies

inserting date into mySQL date column

I have an online appointment system that stores 0000-00-00

         

1rhyno

2:12 pm on Jun 24, 2008 (gmt 0)

10+ Year Member



Hi all,
I have read a couple posts on this but I can not get the answers to correlate to my issue.

I have a form, table, the form has a field called 'Appointment Date' with a name of 'appointment'

The table has a column of date_made with a date datatype.

My php look like this;
INSERT INTO `tblappointments`... VALUES ( '.$_REQUEST['date'].', ...');

When I look at the db all I see is 0000-00-00 and not the entered date.

The date entered is in the format YYYY-MM-DD.

Please help me....

NevadaSam

2:42 pm on Jun 24, 2008 (gmt 0)

10+ Year Member



You may need to include brackets around your variable like: VALUES(...,'{$_REQUEST['date']}',...);

To find out exactly what date is being submitted use a temporary scrip like this just before sending the information to mysql:

echo $_REQUEST['date'];
exit();

Sam
;

1rhyno

3:06 pm on Jun 24, 2008 (gmt 0)

10+ Year Member



Thanks for the reply but no it doesn't matter if there are '{' or not... still saves the date as 0000-00-00 :(

dreamcatcher

3:16 pm on Jun 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you echo the var to see what is coming in as previously mentioned? Or to view the whole array do the following:

print_r($_REQUEST);

dc

1rhyno

4:01 pm on Jun 24, 2008 (gmt 0)

10+ Year Member



what is coming in is '2008-06-24' What is going out is '0000-00-00'

The whole array is;
appointment_date = '0000-00-00'
appointment_time= "10:00 AM"
contact_fk = "3"
not sure I understand your question dreamcatcher

dreamcatcher

8:24 am on Jun 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was just asking if you had tested what was coming in, which you have. Looks as though your date var isn`t between quotes:

mysql_query("INSERT INTO table VALUES ('{$_REQUEST['date']}', ...')...

or

mysql_query("INSERT INTO table VALUES ('".$_REQUEST['date']."', ...')...

dc

1rhyno

11:07 am on Jun 25, 2008 (gmt 0)

10+ Year Member



Thank you so much DC.... You have solved my issue....

dreamcatcher

7:10 pm on Jun 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Anytime my friend,

dc