• Notice regarding image hosts and attachments. See here.

mysql and dates

Associate
Joined
13 Nov 2003
Posts
1,568
Location
Manchester
Hi All

Having some major problems getting mysql to play nice

I need to insert dates into a table. i have set the field to date format, not dame time

But when I try to insert a date into the table with the sql below I get an error

Code:
<?php require_once('../Connections/essential.php'); ?>
<?php
//Get the date variables from the form on the previous page //
$picdate = $_POST['date']
?>
<?php
//Insert the new date value into the gallery_dates table //
mysql_query("INSERT INTO `gallery_dates` ( `id` , `date` ) 
VALUES (
NULL , '$picdate'
); ") 
or die(mysql_error());

I get this error

Incorrect date value: '' for column 'date' at row 1

Now I can go into php admin and insert exactly the same thing and it works, ie the date as a date and not a string.

Does anyone have any ideas, its driving me mental

Aaron
 
Im still working on it and developing it. Once its all working I will tidy it up and escape the user input

:)
 
ive had problems like this and in my case it appeared to be down to the format of the date

ie: sql being setup as american date and code in uk etc etc

have a look into that maybe ?
 
Back
Top Bottom