Jump to content

Please help with update problem


lingo5

Recommended Posts

Hi,

I have the following query to update a record:

 

$idcliente = $_POST['id_cliente'];
$shippingsliptitle = $_POST["shippingslip_title"];
//convert date format
list($dia,$mes,$ano)=explode("-",$_POST['shippingslip_date']);
$shippingslipdate="$ano-$mes-$dia";
$shippingslipnumber=$_POST["shippingslip_number"];



$Sql="UPDATE t_shippingslips SET 
id_cliente='$idcliente', shippingslip_title='$shippingsliptitle', shippingslip_date='$shippingslipdate', shippingslip_number='$shippingslipnumber',shippingslip_path='$filePath' WHERE id_shippingslip='$colname_presupuestos_RS'";

$res=mysql_query($Sql) or die ("Error: ". mysql_error(). " with query ". $Sql);

 

The problem is the date field resets to 00-00-0000 in the DB if I don't change the date ij the update orm. How can I fix this?

Thanks

Link to comment
https://forums.phpfreaks.com/topic/252603-please-help-with-update-problem/
Share on other sites

ooops...sorry guys, I have solved this.

The problem was with the date input field. I had it setup like this:

 

<input name="shippingslip_date" type="text" class="CP_loginFormFields" id="shippingslip_date" value="<?php echo date('d/m/Y',strtotime($row_presupuestos_RS['shippingslip_date'])); ?>" size="32"  />

 

but the date separator I am using is "-".

So I changes the code to this

<input name="shippingslip_date" type="text" class="CP_loginFormFields" id="shippingslip_date" value="<?php echo date('d-m-Y',strtotime($row_presupuestos_RS['shippingslip_date'])); ?>" size="32"  />

 

...and it works now.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.