won't update

1Tsme1941

Member
Please take a look at my code(s) and offer advice.
The first is a form to update a database row and
the second is to update. I get a message that the
update is made but it is not.
================================================
the form:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>update form</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
.wrapper{
width: 500px;
margin: 0 auto;
}
</style>
</head>
<body bgcolor=#ccffff>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h2>mischg-update Form</h2>
</div>
<form action="mischg-update.php" method="post">

<div class="form-group">
<label>Unit</label>
<input type="text" name="unit" class="form-control">
</div>
<div class="form-group">
<label>Chgmoyr</label>
<input type="text" name="chgmoyr" class="form-control">
</div>
<div class="form-group">
<label>Misc</label>
<input type="text" name="misc" class="form-control">
</div>
<div class="form-group">
<label>Damage</label>
<input type="text" name="damage" class="form-control">
</div>
<div class="form-group">
<label>Courtcost</label>
<input type="text" name="courtcost" class="form-control">
</div>
<div class="form-group">
<label>Nsf</label>
<input type="text" name="nsf" class="form-control">
</div>
<div class="form-group">
<label>Latechg</label>
<input type="text" name="latechg" class="form-control">
</div>
<div class="form-group">
<label>Datepaid</label>
<input type="text" name="datepaid" class="form-control">
</div>
<div class="form-group">
<label>Late</label>
<input type="text" name="late" class="form-control">
</div>
<div class="form-group">
<label>Secdep</label>
<input type="text" name="secdep" class="form-control">
</div>
<input type="submit" class="btn btn-primary" name="submit" value="Submit">

</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body></html>
=================================================
the update code:
<?php
//Open a new connection to the MySQL server
require_once "getprerentdb.php";
$chgmoyr = $_POST['chgmoyr'];
$misc = $_POST['misc'];
$damage = $_POST['damage'];
$courtcost = $_POST['courtcost'];
$nsf = $_POST['nsf'];
$latechg = $_POST['latechg'];
$datepaid = $_POST['datepaid'];
$late = $_POST['late'];
$secdep = $_POST['secdep'];
$sql = "UPDATE payments SET
chgmoyr = '$chgmoyr', misc = '$misc', damage = '$damage', courtcost = '$courtcost', nsf = '$nsf',
latechg = '$latechg', datepaid = '$datepaid', late = '$late', secdep = '$secdep'
WHERE unit='".$_POST['unit']."'";
echo "Record for unit ".$_POST["unit"]." has been updated";
?>
 

Cromewell

Administrator
Staff member
I get a message that the
update is made but it is not.
Well, you are not executing your query:
$sql = "UPDATE payments SET
chgmoyr = '$chgmoyr', misc = '$misc', damage = '$damage', courtcost = '$courtcost', nsf = '$nsf',
latechg = '$latechg', datepaid = '$datepaid', late = '$late', secdep = '$secdep'
WHERE unit='".$_POST['unit']."'";
echo "Record for unit ".$_POST["unit"]." has been updated";
 
Top