2 Replies - 188 Views - Last Post: 05 February 2012 - 01:30 AM Rate Topic: -----

Topic Sponsor:

#1 decongh  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 39
  • Joined: 31-December 11

Update is doing insert and not update

Posted 04 February 2012 - 06:58 AM

Why would an update script do an insert, and not update?

$navtype = $_GET['nav'];
 
if($navtype == "zjxpmovdtzjd")
{
 
$mileage_out = $_POST['mileage_out'];
$mileage_in = $_POST['mileage_in'];
$famount = $_POST['famount'];
$vreg = $_POST['vreg'];
$driver = $_POST['driver'];
$vtype = $_POST['vtype'];
$desti = $_POST['desti'];
$date_out = $_POST['dy']."-".$_POST['dm']."-".$_POST['dd'];
$date_in = $_POST['ay']."-".$_POST['am']."-".$_POST['ad'];
$cur_date = date("d-m-y H:i:s");
$outl = $_POST['outl'];
$out2 = $_POST['out2'];
$pload = $_POST['pload'];
$con_size = $_POST['con_size'];
$sup_name = $_POST['sup_name'];
$s_veration = $_POST['s_veration'];
$remnder_ver = $_POST['remnder_ver'];
$tf_con = ($_POST['mileage_in'] - $_POST['mileage_out']);
$tf_con = ($famount * 100) / $tf_con;
$tt_con = $_POST['tt_con'];
 
$sql = "UPDATE movlog
 
SET
 
(mileage_out='$mileage_out',mileage_in='$mileage_in',famount='$famount',vreg='$vreg',driver='$driver',vtype='$vtype',desti='$desti',date_out='$date_out',date_in='$date_in',cur_date='$cur_date',outl='$outl',out2='$out2',
pload='$pload',con_size='$con_size',sup_name='$sup_name',s_veration='$s_veration',remnder_ver='$remnder_ver',
tf_con='$tf_con',tt_con='$tt_con' WHERE id='$id')";
 
mysql_query($sql);
 
$sqlx = "UPDATE sre_log SET current_mileage = '$mileage_in' WHERE vreg='$vreg'";
mysql_query($sqlx);
 
echo "<center><p><br><br><br><strong>The movement log for $vreg has been UPDATE.</strong></p>";
 
}


Is This A Good Question/Topic? 0
  • +

Replies To: Update is doing insert and not update

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 2147
  • View blog
  • Posts: 5,431
  • Joined: 08-June 10

Re: Update is doing insert and not update

Posted 04 February 2012 - 07:28 AM

how do you know it’s been doing an insert?
Was This Post Helpful? 0
  • +
  • -

#3 decongh  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 39
  • Joined: 31-December 11

Re: Update is doing insert and not update

Posted 05 February 2012 - 01:30 AM

becouse it inserts and do update the records
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1