lingo5 Posted December 6, 2011 Share Posted December 6, 2011 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 More sharing options...
lingo5 Posted December 6, 2011 Author Share Posted December 6, 2011 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 https://forums.phpfreaks.com/topic/252603-please-help-with-update-problem/#findComment-1295058 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.