> Hi guys, I blinked and got lost. All I want to do is copy Payfile to Pmtfile and then update records in
Payfile that have been paid(amtpaid !=''). The update doesn't happen and the insert-note comments at botom of post.
<?php
$link = mysqli_connect("localhost", "root", "", "prerentdb");
// Check connection
if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); }
$id = ' ';
$tenant = 'tenant';
$unit = 'unit';
$amtdue = 'amtdue';
$amtpaid = 'amtpaid';
$dueday = 'dueday';
$late = 'late';
$prevbal = 'prevbal';
$latechg = 'latechg';
$secdep = 'secdep';
$damage = 'damage';
$courtcost = 'courtcost';
$nsf = 'nsf';
$chgmoyr = 'chgmoyr';
$hudpay = 'hudpay';
$datepaid = 'datepaid';
$paidsum = 'paidsum';
$comments = 'comments';
$phone = 'phone';
$cell = 'cell';
// Attempt select query execution
$result = mysqli_query($link,"SELECT * FROM payfile");
while($row = mysqli_fetch_array($result)) {
//
//MySqli Insert Query *** inserts strings, not values ***
$sql = "INSERT INTO pmthist (tenant, unit, amtdue, amtpaid, dueday, late, hudpay, paidsum,
datepaid, prevbal, latechg, secdep, damage, courtcost, nsf, chgmoyr, comments, phone, cell)
VALUES('$tenant', '$unit', '$amtdue', '$amtpaid', '$dueday', '$late', '$hudpay', '$paidsum',
'$datepaid', '$prevbal', '$latechg', '$secdep', '$damage', '$courtcost', '$nsf', '$chgmoyr',
'$comments', '$phone', '$cell')";
if ($link->query($sql) === TRUE) { echo "New records created"; }
else { echo "Error: " . $sql . "<br>" . $link->error; }
// Perform a query *** doesn't update ***
$sql = "UPDATE payfile set
amtpaid = '', late ='', hudpay ='', paidsum ='', datepaid ='',
latechg = '', secdep = '', damage = '', courtcost = '', nsf = '', chgmoyr = ' ', comments =' '
WHERE amtpaid =!''";
if ($link->query($sql) === TRUE) { echo "payfile refreshed"; }
else { echo "Error: " . $sql . "<br>" . $link->error; }
}
?>
> This is a record that was supposed to be inserted followed by what was inserted:
1 tenant1 apt1 530.00 530.00
44 tenant unit 0.00 0.00
forgot 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.