I have two date fields in my db, one is a CURRENT_TIMESTAMP and the other Date.

I use a date picker to input the date into the date fields in my form.

All other date in the form is input into my db, except the two date fields.

But when i echo both date fields to see if it has been sent by the from, i see it echo,
but just can get into the db

Any help???

This is the insert script below:
if($navtype == "serxbh")
 {
		 $com_name = $_POST['com_name'];
		 $loc = $_POST['loc'];
		 $name_mech = $_POST['name_mech'];
		 $vtype = $_POST['vtype'];
		 $vreg = $_POST['vreg'];
		 $dept = $_POST['dept'];
		 $ser_notes = $_POST['ser_notes'];
		 $last_startdate = $_POST['last_startdate'];
		 $due_end_date = $_POST['due_end_date'];
		 $data_in = $_POST['data_in'];
		 $put_by = $_POST['put_by'];
		 			
		

		 	 
$sql = "insert INTO logdata

(com_name,loc,name_mech,vtype,vreg,dept,ser_notes,last_startdate,due_end_date,data_in,put_by) 
			values 
			('$com_name','$loc','$name_mech','$vtype','$vreg','$dept','$ser_notes','$last_startdate','$due_end_date','$data_in','$put_by')";
			
			
		//echo "[ $last_startdate ]"; 
		//echo "$due_end_date";
		
			mysql_query($sql);
		echo
		"
		<table bgcolor='#ffffff' align='center' width='100%' height='50'>
		<tr>
		<td class='fonts2' align='center' valign='top'>
			<br><strong>Reminder for vehicle # <font color='red'>[ $vreg ]</font> Has Been Added</strong>
		</td>
		
		</tr>
		</table>";
	}

if your dates have any special characters it might be throwing it off try this

$last_startdate = addslashes($_POST['last_startdate']);
$due_end_date = addslashes($_POST['due_end_date']) ;

also if you want to save some space

$sql = "insert INTO logdata
 
(com_name,loc,name_mech,vtype,vreg,dept,ser_notes,last_startdate,due_end_date,data_in,put_by)
values
('".$_POST['com_name']."','".$_POST['loc']."','".$_POST['name_mech']."','".$_POST['vtype']."','".$_POST['vreg']."','".$_POST['dept']."','".$_POST['ser_notes']."','$last_startdate','$due_end_date','$data_in','$put_by')";

i didnt do all of them but you get the idea

Thank you for the info,am grateful This is what i get when i echo out the SQL query string

insert INTO sre_log 

(com_name,loc,name_mech,vtype,vreg,dept,ser_notes,last_startdate,due_end_date,data_in,put_by) 

values ('Tema Pertrol','London','John','Folk Lift','ER 0010 11','Engineering','To Day is the ','21-12-2011','28-12-2011','','')

also if you want to save some space

$sql = "insert INTO logdata
 
(com_name,loc,name_mech,vtype,vreg,dept,ser_notes,last_startdate,due_end_date,data_in,put_by)
values
('".$_POST['com_name']."','".$_POST['loc']."','".$_POST['name_mech']."','".$_POST['vtype']."','".$_POST['vreg']."','".$_POST['dept']."','".$_POST['ser_notes']."','$last_startdate','$due_end_date','$data_in','$put_by')";

i didnt do all of them but you get the idea

this is the correct format: 2011-05-02 15:08:23
if you are not using time use YYYY-MM-DD 00:00:00
:)

commented: useful post +6

also if you want to save some space ... i didnt do all of them but you get the idea

Putting $_POST values directly into a query is a very bad idea.

The date format you are using is not correct ...

its
'yyyy-mm-dd hh::mm::ss'

I just notice that my date picker inputs the date this way '21-12-2011' and not like this [2011-12-21],i think this may be the reason.

Is there a function i can use to re-arrange it to [YYYY-MM-DD]?

Which function will that be?

I have also two fields in my form one for Time Out and the other for Time In,

i notice that

Time In

over writes

Time Out

. The time type is 'Time' Am i doing some thing wrong.

if($navtype == "movement")
	{
		 $mileage_out = $_POST['mileage_out'];
		 $mileage_in = $_POST['mileage_in'];
		 $ftype = $_POST['ftype'];
		 $famount = $_POST['famount'];
		 $vreg = $_POST['vreg'];
		 $driver = $_POST['driver'];
		 $vtype = $_POST['vtype'];
		 $dept = $_POST['dept'];
		 $date_out = $_POST['date_out'];
		 $date_in = $_POST['date_in'];
		 $time_out = $_POST['time_out'];
		 $time_in = $_POST['time_in'];
		 $tt_con = $_POST['tt_con'];
		 $tf_con = $_POST['tf_con'];
		 
		 
		 $sql = "insert into movlog 
		 
		 values ('','$mileage_out','$mileage_in','$ftype','$famount','$vreg','$driver','$vtype','$dept','$date_out','$date_in','$time_in','$time_in','$tt_con','$tf_con')";
		 
		 mysql_query($sql);
		 
		 echo "<center><p><br><br><br><strong>The $vreg movement has been added to the database</strong></p>";
		 
		 echo"
		      //$time_out
			  //$time_in
		 ";
	}

re-arrange the date:
do this.

$temp_date_in=explode('-',$date_in);
$date_in=$temp_date_in[2]."-".$temp_date_in[1]."-".$temp_date_in[0];

I just notice that my date picker inputs the date this way '21-12-2011' and not like this [2011-12-21],i think this may be the reason.
Is there a function i can use to re-arrange it to [YYYY-MM-DD]?
Which function will that be?

Am sure if you use a datepicker, that you can set the output format in the settings. If not, get a better datepicker.

Do you mean it should look like this?

I did it and it still not working.

if($navtype == "zjxpmovdtzjd")
	{
		 $mileage_out = $_POST['mileage_out'];
		 $mileage_in = $_POST['mileage_in'];
		 $ftype = $_POST['ftype'];
		 $famount = $_POST['famount'];
		 $vreg = $_POST['vreg'];
		 $driver = $_POST['driver'];
		 $vtype = $_POST['vtype'];
		 $dept = $_POST['dept'];		 
		 $temp_date_out=explode('-',$date_out);
         $date_out=$temp_date_out[2]."-".$temp_date_out[1]."-".$temp_date_out[0];
		 $temp_date_in=explode('-',$date_in);
         $date_in=$temp_date_in[2]."-".$temp_date_in[1]."-".$temp_date_in[0];		 
		 $time_out = $_POST['time_out'];
		 $time_in = $_POST['time_in'];
		 $tt_con = $_POST['tt_con'];
		 $tf_con = $_POST['tf_con'];
		 
		 
		 $sql = "insert into movlog 
		 
		 values ('','$mileage_out','$mileage_in','$ftype','$famount','$vreg','$driver','$vtype','$dept','$date_out','$date_in','$time_in','$time_out','$tt_con','$tf_con')";
		 
		 mysql_query($sql);
		 
		 echo "<center><p><br><br><br><strong>The  movement log for $vreg has been added.</strong></p>";
		 
		 echo"
		      $date_out
			  $date_in

yes

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.