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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.