₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,134 members, 8,420,511 topics. Date: Thursday, 04 June 2026 at 10:50 PM

Toggle theme

Ckdoublene's Posts

Nairaland ForumCkdoublene's ProfileCkdoublene's Posts

1 2 (of 2 pages)

ProgrammingInsert Not Working by ckdoublene(op): 7:27pm On Apr 14, 2011
can someone help me figure out why this code doesn't insert data into the database ?
My other problem here is that I dont know how to determine a date a month in the future(duedate).  It doesn't have to be concise.

<?php?>
<html><head>
<?php
include("getinvno.php"wink;
?>
<script type="text/javascript">
var today = new Date();
var date = today.getMonth() + " / " + today.getDate() + " / " + today.getFullYear();
</script>
</head>
<body onload="document.form.ordernum.focus()">

<!--increment date to create due date (next month)-->

<br><script type="text/javascript">
document.write(date);
</script>
<form name="form">
<input type="text" size="5" name="ordernum" id="ordernum"MAXLENGTH=5
onkeyup="getResults();if(this.value.length==this.size)document.form.invnum.focus();" />Order No:

<input type="text" size="5" name="invnum" id="invnum" />Invoice No:

AR/AP: <SELECT name=payrec>
<OPTION class=highlight value=ar selected>R
<OPTION class=highlight value=ap>P
</OPTION></SELECT><br>
<b>Bill</b> - Name: <INPUT TYPE="text" name=bname>
Street: <INPUT TYPE="text" name=bstreet>
State: <SELECT name=bstate>
<OPTION class=highlight value=fl selected>Florida
<OPTION class=highlight value=ga>Georgia
<OPTION class=highlight value=al>Alabama
<OPTION class=highlight value=la>Louisiana
<OPTION class=highlight value=sc>South Carolina
</OPTION></SELECT>
City: <INPUT TYPE="text" name="bcity"><br>
</OPTION></SELECT>
Zip: <INPUT TYPE="text" size=5name="bzip" MAXLENGTH=5
onKeyUp="if(this.value.length==this.size)document.form.contact.focus();"><br>
<b>Contact: </b><INPUT TYPE="text" name=contact><BR>
<b>Ship</b> - Name:
<INPUT TYPE="text" name=sname>
Street <INPUT TYPE="text" name=sstreet>
State <SELECT name=sstate>
<OPTION class=highlight value=fl selected>Florida
<OPTION class=highlight value=ga>Georgia
<OPTION class=highlight value=al>Alabama
<OPTION class=highlight value=la>Louisiana
<OPTION class=highlight value=sc>South Carolina
</OPTION></SELECT>
City: <INPUT TYPE="text" name="scity"><br>
</OPTION></SELECT>
Zip: <INPUT TYPE="text" size=5name="szip" MAXLENGTH=5
onKeyUp="if(this.value.length==this.size)document.form.terms.focus();"><p>
Terms: <SELECT name=terms>
<OPTION class=highlight value=net 10 selected>Net 10
<OPTION class=highlight value=1_10_30ga>1 10 Net 30
<OPTION class=highlight value=2_10_30>2 10 Net 30
<OPTION class=highlight value=cash>Cash
</OPTION></SELECT>
FOB: <SELECT name=fob>
<OPTION class=highlight value=Destination selected>Destination
<OPTION class=highlight value=Origin>Origin
</OPTION></SELECT><p>
<b>Dates</b> - Ordered:
<INPUT TYPE="text" size=10 name="dateord" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.datecomp.focus();">
Completed: <INPUT TYPE="text" size=10 name="datecomp" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.duedate.focus();">
Due: <INPUT TYPE="text" size=10 name="duedate" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.datepaid.focus();">
Paid: <INPUT TYPE="text" size=10 name="datepaid" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.qty.focus();"><p>
Qty: <INPUT TYPE="text" size=5 name=qty>
Description: <INPUT TYPE="text" size=25 name=descr>
Charges: <INPUT TYPE="text" size=7 name=charges>
Paid Amt: <INPUT TYPE="text" size=7 name=paidamt>
Tax: <INPUT TYPE="text" size=6 name tax><p>
<b>Shipping</b> - Date:
<INPUT TYPE="text" size=10 name "shipdate" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.shipamt.focus();">
Amt:<INPUT TYPE="text" size=7 name shipamt><p>
<b>Amount Due</b>: <INPUT TYPE="text" size=7 name=amtdue><p>
<input type="submit" value="submit data" />
</p>
</form>
</body></html>
<?php
if (isset( $_POST['payrec']) )
{
$pd=$_POST['pd'];
$payrec=$_POST['payrec'];
$ordernum=$_POST['ordernum'];
$invnum=$_POST['invnum']; 
$bname=$_POST['bname']; 
$bstreet=$_POST['bstreet']; 
$bstate=$_POST['bstate'];
$bcity=$_POST['bcity'];
$bzip=$_POST['bzip'];
$sname=$_POST['sname']; 
$sstreet=$_POST['sstreet']; 
$sstate=$_POST['sstate'];
$scity=$_POST['scity'];
$szip=$_POST['szip'];
$contact=$_POST['contact'];
$terms=$_POST['terms'];
$fob=$_POST['fob'];
$shipdate=$_POST['shipdate'];
$shipamt=$_POST['shipamt']; 
$dateord=$_POST['dateord'];
$datecomp=$_POST['datecomp'];
$duedate=$_POST['duedate']; 
$datepaid=$_POST['datepaid'];
$qty=$_POST['qty']; 
$desc=$_POST['descr']; 
$charges=$_POST['charges']; 
$paidamt=$_POST['paidamt'];
$dayslate=$_POST['dayslate']; 
$tax=$_POST['tax'];
$amtdue=$_POST['amtdue'];
$paidsum=$_POST['paidsum'];
}
mysql_connect(localhost,root,""wink;
mysql_select_db(oodb) or die( "Unable to select database"wink;
$query = "
INSERT INTO oocust (pd,payrec,ordernum,invnum,bname,bstreet,bstate,bcity,bzip,sname,sstreet,sstate,scity,szip,contact,terms,fob,shipdate,shipamt,dateord,datecomp,duedate,datepaid,qty,descr,charges,paidamt,
dayslate,tax,amtdue,paidsum)
VALUES('$pd','$payrec','$ordernum','$invnum','$bname','$bstreet','$bstate','$bcity','$bzip','$sname','$sstreet','$sstate','$scity','$szip','$contact','$terms','$fob','$shipdate','$shipamt','$dateord','$datecomp','$duedate','$datepaid','$qty','$descr',
'$charges','$paidamt','$dayslate','$tax','$amtdue','$paidsum')";
echo "data inserted</font>

";
$stat = mysql_query($query) or die('Query failed: ' . mysql_error());
mysql_close();
?>
ProgrammingParse Error: Syntax Error, Unexpected T_else In C:\ by ckdoublene(op): 11:08pm On Apr 07, 2011
Someone please help me to finish this code?
<?php?>
<HTML><HEAD>
<script type="text/javascript">
var monthNames = [ "January","February","March","April","May","June","July",
"August","September","October","November","December" ];
var today = new Date();
var date = monthNames[today.getMonth()] + " - " + today.getDate() + " / " + today.getFullYear();
</script>
</script>
</HEAD><BODY>
<script type="text/javascript">document.write (date);
</script>
<?php
mysql_connect(localhost,root,""wink;
mysql_select_db(oodb) or die( "Unable to select database"wink;
if(!empty($_POST["submit"]))
{
$ordernum = $_POST['ordernum'];
$query=" SELECT * FROM oocust WHERE ordernum='$ordernum'AND PD=' '";
$result=mysql_query($query);
if(mysql_num_rows($result))
{
$ordernum = $_POST['ordernum'];
$invnum = $_POST['invnum'];
$bname = $_POST['bname'];
$bstreet = $_POST['bstreet'];
$bstate = $_POST['bstate'];
$bzip = $_POST['bzip'];
$sname = $_POST['sname'];
$sstreet = $_POST['sstreet'];
$sstate = $_POST['sstate'];
$szip = $_POST['szip'];
$contact = $_POST['contact'];
$terms = $_POST['terms'];
$fob = $_POST['fob'];
$shipdate = $_POST['shipdate'];
$shipamt = $_POST['shipamt'];
$dateord = $_POST['dateord'];
$datecomp = $_POST['datecomp'];
$duedate = $_POST['duedate'];
$datepaid = $_POST['datepaid'];
$qty = $_POST['qty'];
$desc = $_POST['desc'];
$charges = $_POST['charges'];
$paidamt = $_POST['paidamt'];
$owed = $_POST['owed'];
$dayslate = $_POST['dayslate'];
$tax = $_POST['tax'];
$amtdue = $_POST['amtdue'];
}
// charges + tax + shipping = $gtotal
$gtotal = $charges + $tax + $shipamt;

echo "<form action='#' method='post'>echo 'Old Orchard Plumbing<br>
2210 E. Hogan Hollow Road<br>
Margate, Fl, 33063<br>'";
while ($row = mysql_fetch_assoc($result) )
{
echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5>
<TR>
<th>Bill To</th>
<th>Ship to</th>
<th>Invoice No</th>
<th>Terms</th>
<th>Due Date</th>
<th>Fob</th>
<th>Ship Date</th>
<th>Order No</th>
<tr>
<TH colspan=11>================================================================================================</TH>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['bname'] . "</td>";
echo "<td>" . $row['sname'] . "</td>";
echo "<tr>";
echo "<td>" . $row['bstreet'] . "</td>";
echo "<td>" . $row['sstreet'] . "</td>";
echo "<tr>";
echo "<td>" . $row['bstate'] . "</td>";
echo "<td>" . $row['sstate'] . "</td>";
echo "<tr>";
echo "<td>" . $row['bcity'] . "</td>";
echo "<td>" . $row['scity'] . "</td>";
echo "<tr>";
echo "<td>" . $row['bzip'] . "</td>";
echo "<td>" . $row['szip'] . "</td>";
echo "<td>" . $row['invnum'] . "</td>";
echo "<td>" . $row['terms'] . "</td>";
echo "<td>" . $row['duedate'] . "</td>";
echo "<td>" . $row['fob'] . "</td>";
echo "<td>" . $row['shipdate'] . "</td>";
echo "<td>" . $row['ordernum'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5>
<TR>
<th>Desc</th>
<th>Qty</th>
<th>Charges</th>
<th>Tax(6%)</th>
<th>Ship Amt</th>
<th>Amt Due</th>
<th>Gtotal</th>
<tr>
<TH colspan=11>================================================================================================</TH>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['desc'] . "</td>";
echo "<td>" . $row['qty'] . "</td>";
echo "<td>" . $row['charges'] . "</td>";
echo "<td>" . $row['tax'] . "</td>";
echo "<td>" . $row['shipamt'] . "</td>";
echo "<td>" . $row['amtdue'] . "</td>";
echo "<td>" . $row['paidamt'] . "</td>";
echo "<td>" . $row['gtotal'] . "</td>";
echo "<tr>";
}
echo "</table>";
echo "</form>";
{
else{echo "No listing for order# $ordernum.
Select another?
";}
}
mysql_close();
?>
<form method="post" action="#">

<input type="text" name="ordernum"/><p>
<input type="submit" name="submit" value="+"/></form>
ProgrammingRe: Need Help With Insert by ckdoublene(op): 8:01am On Feb 07, 2011
Sweetheart, you speak my language so I don't understand the difficutlty explaining to you.   The below code says that all records in the database table which having the paidsum = rentdue or any records that have L in the late field should have the specified values  cleared (zeros or blanks).  This is to start the new month with a report ready to register payments for the new month.  The below code does that.  I want to expand the program to add $10 to the latechg field of any tenants who haven't paid the full rent (paidsum < rentdue) and increase the prevbal by the amount of the rent still owed (prevbal = prevbal +( rentdue - paidsum) for those late payers.  I have one glass of milk  - with marshmalloows in it - and cookies. Every cookie  I find in it, I want to remove. What am I saying, I'd rather have the cookies. This is the original problem with the original code.
<?php
$stat = mysql_connect("localhost","root",""wink;
$stat = mysql_select_db("prerentdb"wink;
$query = "SELECT name FROM payments Where apt='$apt'";
$stat = @mysql_fetch_assoc(mysql_query($query));
echo $stat["name"];
$sql = "UPDATE payments SET
amtpaid = 0, prevbal = 0,hudpay = 0, tentpay = 0, datepaid = ' ', late = ' ',
comments = ' ', paidsum = 0 WHERE paidsum = rentdue OR late = 'L'";
mysql_query($sql) or die("Update query failed."wink;
echo "Records have been updated";
?>
ProgrammingRe: Need Help With Insert by ckdoublene(op): 10:52pm On Feb 06, 2011
the WHERE statement dictates which data is updated. You are referring to the original program?
ProgrammingRe: Need Help With Insert by ckdoublene(op): 5:18am On Feb 06, 2011
Sweet, no there is no form.  I just read one table(current month's payments), which I refresh each month (the unresolved program) and insert the data into the next table(a history of payments). 
Don't tell me mosquitos are getting to you while you're at the computer? Here in Florida we have trouble with mosquitos during the warm months but not in the cooler months.  When I go hunting, if I'm near water , sometimes.  Still haven't figured out how to add the "add 10 to latechg" in the other program.
ProgrammingRe: Need Help With Insert by ckdoublene(op): 9:09pm On Feb 05, 2011
Sorry, I should have cleared this earlier. This was the solution:
<?php
$stat = mysql_connect(localhost,root,""wink or die('Unable to connect to database: ' . mysql_error());
$stat = mysql_select_db(prerentdb) or die('Unable to select database: ' . mysql_error());
$query = "INSERT INTO prerenthist
(name,apt,amtpaid,rentdue,prevbal,hudpay,tentpay,datepaid,late,comments,paidsum)
SELECT name,apt,amtpaid,rentdue,prevbal,hudpay,tentpay,datepaid,late,comments,paidsum
FROM payments";
echo "apt $apt data inserted</font>

";
$stat = mysql_query($query) or die('Query failed: ' . mysql_error());
mysql_close();
?>
ProgrammingNeed Help With Insert by ckdoublene(op): 9:22pm On Feb 04, 2011
I'm trying to acquire data from one table(payments) and insert it into another (prerenthist).  Both tables are in the same database (prerentdb).  I get error message:
Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\hofiles\prerentadd.php on line 9
the code is below.  ?

<?php
$stat = mysql_connect(localhost,root,""wink or die('Unable to connect to database: ' . mysql_error());
$stat = mysql_select_db(prerentdb) or die('Unable to select database: ' . mysql_error());
$query = "INSERT INTO prerenthist (name,apt,amtpaid,rentdue,prevbal,hudpay,tentpay,datepaid,late,comments,paidsum)
SELECT name,apt,amtpaid,rentdue,prevbal,hudpay,tentpay,datepaid,late,comments,paidsum
FROM PAYMENTS;
$stat = mysql_query($query) or die('Query failed: ' . mysql_error());   
echo "data inserted</font>

"; 
mysql_close();
?>
ProgrammingRe: Help With Update by ckdoublene(op): 4:15pm On Feb 02, 2011
I figured that was a Nigerian saying - in plain English, what's the meaning?  When I saw the new code I thought "alright, that's what I was trying in the beginning" - but no, it did nothing to the database records.  I got the message "records have been updated" but when I displayed the file it hadn't changed.
ProgrammingRe: Help With Update by ckdoublene(op): 5:22am On Feb 01, 2011
You want to know where such a dummy's from? Florida, USA - you? You're saying I can read & only update the database file by using the WHERE statement? I'm trying to avoid reports & don't know the values to enter before making comparisons ( late = 'L') I'm getting the variables the same place (WHERE paidsum = rentdue)
ProgrammingRe: Help With Update by ckdoublene(op): 8:19pm On Jan 30, 2011
you know, this is futile.  This is(should be) such a simple little program.  All was good when I used the below program
<?php
$stat = mysql_connect("localhost","root",""wink;
$stat = mysql_select_db("prerentdb"wink;
$query = "SELECT name FROM payments Where apt='$apt'";
$stat = @mysql_fetch_assoc(mysql_query($query));
echo $stat["name"];
$sql = "UPDATE payments SET
amtpaid = 0, prefvbal - 0, hudpay = 0, tentpay = 0, datepaid = ' ', late = ' ', paidsum = 0
WHERE paidsum = rentdue OR late = ''L'";
mysql_query($sql) or die("Update query failed."wink;
echo "Records have been updated";
?>

using Set,   Where paidsum = rentdue OR late = ''L', but when I tried to also "add the $10 to the latechg if the paidsum < rentdue " I got lost.
ProgrammingRe: Help With Update by ckdoublene(op): 1:56am On Jan 30, 2011
yeah I click on the xammp control and start the apache and mysql every morning, then click on the shortcut to launch my site and everything runs great except that I never got this program to execute right.
ProgrammingRe: Help With Update by ckdoublene(op): 8:12pm On Jan 29, 2011
ther is no html code, I just read the database records and update them
ProgrammingRe: Help With Update by ckdoublene(op): 5:31pm On Jan 29, 2011
this is the current code.  no errors, just clears the fields and the message "records have been updated".
<?php
$apt=$_POST['apt']; 
$amtpaid=$_POST['amtpaid'];
$rentdue=$_POST['rentdue']; 
$prevbal=$_POST['prevbal'];
$hudpay=$_POST['hudpay'];   
$tentpay=$_POST['tentpay']; 
$datepaid=$_POST['datepaid'];
$late=$_POST['late']; 
$paidsum=$_POST['paidsum'];
$stat = mysql_connect("localhost","root",""wink;
$stat = mysql_select_db("prerentdb"wink;
$query = "SELECT name FROM payments Where apt='$apt'";
$stat = @mysql_fetch_assoc(mysql_query($query));
echo $stat["name"];
if($paidsum<$rentdue)
{
$latechg = $latechg + 10;
}
if($paidsum == $rentdue or $late == 'L')
{
$amtpaid = 0;
$prevbal = 0;
$latechg = 0;
$hudpay = 0;
$tentpay = 0;
$datepaid = ' ';
$late = ' ';;
$comments = ' ';
$paidsum = 0;
}
$sql = "UPDATE payments SET amtpaid='$amtpaid',prevbal='$prevbal',
hudpay='$hudpay',tentpay='$tentpay',datepaid='$datepaid',late='$late',
paidsum='$paidsum'";
mysql_query($sql) or die("Update query failed."wink;
echo "Records have been updated";
?>

I worked out the other program on my own.
ProgrammingRe: Help With Update by ckdoublene(op): 12:06am On Jan 28, 2011
I have designed a system which does all of this and has been working well for many months. I manage an apartment complex and my system has converted everything from paper shuffling and paper file shuffling to instant information acquisition. I still must comply and adhere to corporate figures who do not use any computer. This is the last of many programs and I just need to reset the payment information file. It is a simple program which I had working at one time but I am still learning this language and am soliciting advice. If you have looked at the latest effort here and can see errors in the syntax please advise. If not, thanks anyway.
ProgrammingRe: Help With Update by ckdoublene(op): 10:31pm On Jan 27, 2011
Thanks, the image didn't come through. This program is for an apartment complex.  It is to refresh the payments records at the end of the month. Throughout the month tenants pay their rent(amtpaid) and it is entered into the preren[/b]t (payments) file.  If the tenant has paid the rent later than specified date, a $10 late charge is added to their [b]rentdue and an "L" is inserted into the late column so that, on a report, it is evident why the amtpaid > rentdue.   When executed, this should add $10 to the latechg field( for a late payment history) if the total amount paid[b](paidsum[/b])< rentdue and refresh (clear) the records if the rentdue=amtpaid or if there is a "L" in the[b] late [/b] column.
ProgrammingRe: Can't Find Error by ckdoublene(op): 9:36pm On Jan 27, 2011
sorry sweet, this is an entirely different program.
ProgrammingRe: Help With Update by ckdoublene(op): 9:33pm On Jan 27, 2011
ok, sweet. first, where did you come up with that username?  This is a program to refresh the payment file for an apartment complex at the end of each month.  Is the code below accurate and is it what you're suggesting?

<?php
include ('getnames.php');
if($paidsum < $rentdue)
{
$latechg = $latechg + 10;
}
if($paidsum == $rentdue || $late == 'L')
{
$amtpaid = 0;
$prevbal = 0;
$latechg = 0;
$hudpay = 0;
$tentpay = 0;
$datepaid = ' ';
$late = ' ';
$comments = ' ';
$paidsum = 0;
}
$sql = "UPDATE payments SET
amtpaid='$amtpaid',prevbal='$prevbal','latechg='$latechg',hudpay='$hudpay',
tentpay='$tentpay',datepaid='$datepaid',late='$late',comments='$comments',
paidsum='$paidsum'";
mysql_query($sql) or die("Update query failed."wink;
echo "Records have been updated";
?>
ProgrammingCan't Find Error by ckdoublene(op): 7:55pm On Jan 27, 2011
this code works if I take out the checkbox(repair & replace). otherwise I get a syntax error message pointing to the INSERT statement
<form name="form" action="<?php $_SERVER[PHP_SELF] ?>" method="post">
<input type="text" size="2" name="apt" id="apt"
onkeyup="getResults();if(this.value.length==this.size)document.form.datereceived.focus();" />Apt

<input type="text" size="25" name="name" id="name" />Name

<INPUT TYPE="text" size=10 name="datereceived"
onKeyUp="if(this.value.length==this.size)document.form.time.focus();">Date Received

<INPUT TYPE="text" size=7 name="time">Time Received


<br>Kitchen
<select name="item">
<option value="kitchen blinds" selected>kitchen blinds</option>
<option value="kitchen bifolds">kitchen bifolds</option>
<option value="kitchen lights">kitchen light fixtures</option>
<option value="kitchen bulbs">kitchen light bulbs</option>
<option value="kitchen tile">kitchen tile/linoleum</option>
<option value="kitchen countop">kitchen counter top</option>
<option value="kitchen cabinets">kitchen cabinets</option>
<option value="kitchen drawers">kitchen drawers</option>
<option value="fridge">refidgerator</option>
<option value="stove">stove</option>
<option value="range hood">stove hood</option>
<option value="kitchen sink">kitchen sink</option>
<option value="under kitchensink">under kitchen sink</option>
<option value="kitchen faucet">kitchen faucet</option>
<option value="kitchen drain">kitchen drain</option>
<option value="kitchen screens">kitchen windows & screens</option>
<option value="fire extinguisher">fire extinguisher</option>
<option value="kitchen wall plates">kitchen switch plates</option>
<option value="kitchen outlets">kitchen electrical outlets</option>
<option value="kitchen ceilings">kitchen ceiling paint</option>
<option value="kitchen wallpaint">kitchen wall paint</option>
</select>
<br> repaired <input type=checkbox name="repair" value="Y">
replaced <input type=checkbox name="replace" value="Y"><br>
</p>
action<INPUT TYPE="text" size=100 name="action">

<INPUT TYPE="text" size=2 name="compday" MAXLENGTH=2
onKeyUp="if(this.value.length==this.size)document.form.compmoyr.focus();">
<INPUT TYPE="text" size=7 name="compmoyr" MAXLENGTH=7
Date Completed - <font color=red>day then mm/yyyy</font


cost<INPUT TYPE="text" size=4 name="cost">
charge<INPUT TYPE="text" size=4 name="charge">
Order#<INPUT TYPE="text" size=4 name="ordno"> -  If Insp
<p>
<INPUT type="submit" value="submit data" />
</p>
</form>

<?php
if (isset( $_POST['apt']) ) {
$apt=$_POST['apt']; 
$name=$_POST['name']; 
$datereceived=$_POST['datereceived']; 
$time=$_POST['time']; 
$item=$_POST['item'];
$repair=$_POST['repair']; 
$replace=$_POST['replace'];
$action=$_POST['action']; 
$compday=$_POST['compday']; 
$compmoyr=$_POST['compmoyr']; 
$cost=$_POST['cost']; 
$charge=$_POST['charge']; 
$ordno=$_POST['ordno'];
$stat = mysql_connect("localhost","root",""wink or die('Unable to connect to database: ' . mysql_error()); 
$stat = mysql_select_db("maintdb"wink or die('Unable to select database: ' . mysql_error()); 
$query = "
INSERT INTO maintdata (apt,name,datereceived,time,item,repair,replace,action,compday,compmoyr,cost,charge,ordno)
VALUES('$apt','$name','$datereceived','$time','$item','$repair','$replace','$action','$compday','$compmoyr','$cost','$charge','$ordno')";
echo "apt $apt data inserted</font>

";
$stat = mysql_query($query) or die('Query failed: ' . mysql_error()); 
mysql_close();
}
?>
ProgrammingRe: Help With Update by ckdoublene(op): 4:41pm On Jan 25, 2011
wow, this is wild.  I got your last messages this morning so they couldn't help last night .  It's along way from Florida to you!  Below is the contents of my ill witten getnames.php.It works fine in other programs but being a newbie it could use help.
<?php
$apt=$_POST['search_term'];
$stat = mysql_connect("localhost","root",""wink;
$stat = mysql_select_db("prerentdb"wink;
$query = "SELECT name FROM payments Where apt='$apt'";
$stat = @mysql_fetch_assoc(mysql_query($query));
echo $stat["name"];
?>
I'm posting the current code for the program.  I'd appreciate help with it as I'm not clear what you're trying to tell me:


<?php
include ('getnames.php');
 
if($paidsum < $rentdue)
{
$latechg = $latechg + 10;
}
if($paidsum == $rentdue || $late == 'L')
{
$amtpaid = 0;
$prevbal = 0;
$latechg = 0;
$hudpay = 0;
$tentpay = 0;
$datepaid = ' ';
$late = ' ';
$comments = ' ';
$paidsum = 0;
}
$sql = "UPDATE payments SET
amtpaid = '" . mysql_real_escape_string($_POST['amtpaid']) . "',
prevbal = '" . mysql_real_escape_string($_POST['prevbal']) . "',
latechg = '" . mysql_real_escape_string($_POST['latechg']) . "',
hudpay = '" . mysql_real_escape_string($_POST['hudpay']) . "',
tentpay = '" . mysql_real_escape_string($_POST['tentpay']) . "',
datepaid = '" . mysql_real_escape_string($_POST['datepaid']) . "',
late = '" . mysql_real_escape_string($_POST['late']) . "',
comments = '" . mysql_real_escape_string($_POST['comments']) . "',
paidsum = '" . mysql_real_escape_string($_POST['paidsum']) . "'";
mysql_query($sql) or die("Update query failed."wink;
echo "Records have been updated";
?>
ProgrammingRe: Help With Update by ckdoublene(op): 3:05am On Jan 25, 2011
You caught me between posts.  I lost it when I went back.  I get the message that the update has been made.The values are set to zero.  And I do get my share of error messages.  I'm trying to clear those values if the conditions of the "if " statements are met.  They are cleared as if there were no if statements.  I really appreciate your help.
ProgrammingRe: Help With Update by ckdoublene(op): 2:40am On Jan 25, 2011
the below code did the same thing
<?php
include ('getnames.php');
if($paidsum < $rentdue)
{
$latechg = $latechg + 10;
}
if($paidsum == $rentdue || $late == 'L')
{
$amtpaid = 0;
$prevbal = 0;
$latechg = 0;
$hudpay = 0;
$tentpay = 0;
$datepaid = ' ';
$late = ' ';
$comments = ' ';
$paidsum = 0;
}
$sql = "UPDATE payments SET
amtpaid = '" . mysql_real_escape_string($_POST['amtpaid']) . "',
prevbal = '" . mysql_real_escape_string($_POST['prevbal']) . "',
latechg = '" . mysql_real_escape_string($_POST['latechg']) . "',
hudpay = '" . mysql_real_escape_string($_POST['hudpay']) . "',
tentpay = '" . mysql_real_escape_string($_POST['tentpay']) . "',
datepaid = '" . mysql_real_escape_string($_POST['datepaid']) . "',
late = '" . mysql_real_escape_string($_POST['late']) . "',
comments = '" . mysql_real_escape_string($_POST['comments']) . "',
paidsum = '" . mysql_real_escape_string($_POST['paidsum']) . "'";
mysql_query($sql) or die("Update query failed."wink;
echo "Records have been updated";
?>
ProgrammingRe: Help With Update by ckdoublene(op): 1:35am On Jan 25, 2011
thanks for your response. I did as you suggested but it didn't change anything
ProgrammingHelp With Update by ckdoublene(op): 12:07am On Jan 25, 2011
this code clears the fields every time.  the if statements are not executed.  can someone help with this, please?
<?php
include ('getnames.php');
if(paidsum < rentdue)
{
latechg == latechg + 10;
}
if(paidsum == rentdue || late == 'L')
{
amtpaid == 0;
prevbal == 0;
latechg == 0;
hudpay == 0;
tentpay == 0;
datepaid == ' ';
late == ' ';
comments == ' ';
paidsum == 0;
}
$sql = "UPDATE payments SET
amtpaid = '" . mysql_real_escape_string($_POST['amtpaid']) . "',
prevbal = '" . mysql_real_escape_string($_POST['prevbal']) . "',
latechg = '" . mysql_real_escape_string($_POST['latechg']) . "',
hudpay = '" . mysql_real_escape_string($_POST['hudpay']) . "',
tentpay = '" . mysql_real_escape_string($_POST['tentpay']) . "',
datepaid = '" . mysql_real_escape_string($_POST['datepaid']) . "',
late = '" . mysql_real_escape_string($_POST['late']) . "',
comments = '" . mysql_real_escape_string($_POST['comments']) . "',
paidsum = '" . mysql_real_escape_string($_POST['paidsum']) . "'";
mysql_query($sql) or die("Update query failed."wink;
echo "Records have been updated";
?>
ProgrammingHow Do I Use This In Several Programs by ckdoublene(op): 8:21pm On Jan 23, 2011
<?php
$apt=$_POST['search_term'];
$stat = mysql_connect("localhost","root",""wink;
$stat = mysql_select_db("prerentdb"wink;
$query = "SELECT name FROM payments Where apt='$apt'";
$stat = @mysql_fetch_assoc(mysql_query($query));
echo $stat["name"];
?>
ProgrammingUnwanted Error Message by ckdoublene(op): 7:01pm On Jan 23, 2011
the below code works but I get the below message every time?
<?php
mysql_connect(localhost,root,""wink;
mysql_select_db(prerentdb) or die( "Unable to select database"wink;
$result=mysql_query($query);
$num=mysql_numrows($result);

$query = "INSERT INTO payhist (name,apt,amtpaid,rentdue,prevbal,
hudpay,tentpay,datepaid,late,comments,paidsum)
Select name,apt,
amtpaid,rentdue,prevbal,hudpay,tentpay,datepaid,late,comments,
paidsum From payments WHERE paidsum < rentdue OR late = 'L'";

$stat = mysql_query($query) or die('Query failed: ' . mysql_error() . " - query: $query"wink;   
echo "data inserted</font>

"; 
mysql_close();

?> 
Warning: mysql_numrows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\hofiles\lateinsert.php on line 4
data inserted
ProgrammingRe: why the unexpected $end by ckdoublene(op): 8:56pm On Jan 02, 2011
I'm sure that  the problem is that I don't know how to state the variables in the javascript so that it works in the php?
ProgrammingRe: why the unexpected $end by ckdoublene(op): 4:40pm On Jan 02, 2011
the below is my new code. I've checked that my database has the rows but nothing happens?
<?php
mysql_connect("localhost","root",""wink;
mysql_select_db("test"wink or die( "Unable to select database"wink;
if(!empty($_POST["submit"]))
{
$apt = $_POST['apt'];
$query="SELECT * FROM payments Where apt='$apt'";
$result=mysql_query($query);
if(mysql_num_rows($result))
{
?>
<html><head><script type="text/javascript">
if ($late = "L"wink {$rentdue = $rentdue + 10;}
var excess = $paidsum - $rentdue;
var totOwed = $rentdue + $prevbal + $secdep + $damage + $latechg + $courtcost +
$nsf - $hudpay;
if ($paidsum >= totOwed) { $prevbal = totOwed - $paidsum;
excess = 0 ; $secdep = 0 ; $damage = 0 ; $latechg = 0 ; $courtcost = 0 ; $nsf = 0; }
if (excess < $prevbal && $paidsum > $rentdue) { $prevbal = $prevbal - excess; excess = 0}
if (excess >= $prevbal) { excess = excess - $prevbal; $prevbal = 0 ; }
if (excess < $secdep && $paidsum > $rentdue) { $secdep = $secdep - excess; excess = 0}
if (excess >= $secdep) { excess = excess - $secdep; $secdep = 0 ; }
if (excess < $damage && $paidsum > $rentdue) { $damage = $damage - excess; excess = 0}
if (excess >= $damage) { excess = excess - $damage; $damage = 0 ; }
if (excess < $latechg && $paidsum > $rentdue) { $latechg = $latechg - excess; excess = 0}
if (excess >= $latechg) { excess = excess - $latechg; $latechg = 0 ; }
if (excess < $courtcost && $paidsum > $rentdue) { $courtcost = $courtcost - excess; excess = 0}
if (excess >= $courtcost) { excess = excess - $courtcost; $courtcost = 0 ; }
if (excess < $nsf && $paidsum > $rentdue) { $nsf = $nsf - excess; excess = 0}
if (excess >= $nsf) { excess = excess - $nsf; $nsf = 0 ; }
}
</script>
<?php
$sql = "UPDATE payments SET
amtpaid = '0',  prevbal, tentpay = '0', datepaid = ' ', late = ' ', damage, courtcost, nsf, latechg, secdep, comments = ' ', paidsum = '0'
WHERE prevbal + rentdue = paidsum OR late = 'L'";
echo $qry;  // so you can see if the data you expect to be update is being updated.
mysql_query($sql);
if ($err = mysql_error()) echo $err;  // show query error
// mysql_query($sql) or die("Update query failed."wink;
echo "Records have been updated";
}
}
?>
<head></html>
ProgrammingUnexpected $end by ckdoublene(op): 12:54am On Jan 02, 2011
I get the message "unexpected $end on the last line.  Can someone help?

<?php
mysql_connect(localhost,root,""wink;
mysql_select_db(test) or die( "Unable to select database"wink;
if(!empty($_POST["submit"]))
{
$apt = $_POST['apt'];
$query="SELECT * FROM payments Where apt='$apt'";
$result=mysql_query($query);
if(mysql_num_rows($result))
{
?>
<html><head><script type="text/javascript">
if ($late = "L"wink {$rentdue = $rentdue + 10;}
var excess = $amtpaid - $rentdue;
var totOwed = $rentdue + $prevbal + $secdep + $damage + $latechg + $courtcost +
$nsf - $hudpay;
if ($amtpaid >= totOwed) { $prevbal = totOwed - $amtpaid;
excess = 0 ; $secdep = 0 ; $damage = 0 ; $latechg = 0 ; $courtcost = 0 ; $nsf = 0; }
if (excess < $prevbal && $amtpaid > $rentdue) { $prevbal = $prevbal - excess; excess = 0}
if (excess >= $prevbal) { excess = excess - $prevbal; $prevbal = 0 ; }
if (excess < $secdep && $amtpaid > $rentdue) { $secdep = $secdep - excess; excess = 0}
if (excess >= $secdep) { excess = excess - $secdep; $secdep = 0 ; }
if (excess < $damage && $amtpaid > $rentdue) { $damage = $damage - excess; excess = 0}
if (excess >= $damage) { excess = excess - $damage; $damage = 0 ; }
if (excess < $latechg && $amtpaid > $rentdue) { $latechg = $latechg - excess; excess = 0}
if (excess >= $latechg) { excess = excess - $latechg; $latechg = 0 ; }
if (excess < $courtcost && $amtpaid > $rentdue) { $courtcost = $courtcost - excess; excess = 0}
if (excess >= $courtcost) { excess = excess - $courtcost; $courtcost = 0 ; }
if (excess < $nsf && $amtpaid > $rentdue) { $nsf = $nsf - excess; excess = 0}
if (excess >= $nsf) { excess = excess - $nsf; $nsf = 0 ; }
}
</script>
<?php>
$sql = "UPDATE payments SET
amtpaid = '0',  prevbal, tentpay = '0', datepaid = ' ', late = ' ', damage, courtcost, nsf, latechg, secdep, comments = ' ', paidsum = '0'
WHERE prevbal + rentdue = amtpaid OR late = 'L');
mysql_query($sql) or die("Update query failed."wink;
echo "Records have been updated";
}
?>
</script></head></html>
ProgrammingRe: why the unexpected $end by ckdoublene(op): 4:19pm On Dec 31, 2010
I have it working now with the below except that if the amtpaid is > totOwed nothing happens?
<script>
function $_(IDS) { return document.getElementById(IDS); }
function calculate_paid() {
   var amtpaid = document.getElementById("amtpaid"wink;
   var rentdue = document.getElementById("rentdue"wink;
var prevbal = document.getElementById("prevbal"wink;
var hudpay = document.getElementById("hudpay"wink;
var tentpay = document.getElementById("tentpay"wink;
var datepaid = document.getElementById("datepaid"wink;
var late = document.getElementById("late"wink;
var damage = document.getElementById("damage"wink;
var courtcost = document.getElementById("courtcost"wink;
var nsf = document.getElementById("nsf"wink;
var latechg = document.getElementById("latechg"wink;
var secdep = document.getElementById("secdep"wink;
  var paidsum = document.getElementById("paidsum"wink;
  var dateNow = new Date();
  var dayNow = dateNow.getDate();
  var datePaid = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear();
datepaid.value = datePaid;
paidsum.value = parseInt(paidsum.value) + parseInt(amtpaid.value);
tentpay.value = parseInt(tentpay.value) + parseInt(amtpaid.value) - parseInt(hudpay.value);
// ******************************************************************************
var totOwed = parseInt(rentdue.value) + parseInt(prevbal.value) + parseInt(secdep.value) + parseInt(damage.value) + parseInt(latechg.value) + parseInt(courtcost.value) +
parseInt(nsf.value) - parseInt(hudpay.value);
if(dayNow > 5) { late.value = "L"; totOwed = totOwed.value + 10; }
var excess = parseInt(amtpaid.value - rentdue.value);
if (amtpaid.value >= totOwed) { prevbal.value = totOwed - amtpaid.value ;
excess = 0 ; secdep.value = 0 ; damage.value = 0 ; latechg.value = 0 ;
courtcost.value = 0 ; nsf.value = 0; }
// ******************************************************************************
if (excess < prevbal.value && amtpaid.value > rentdue.value) { prevbal.value = prevbal.value - excess; excess = 0}
if (excess >= prevbal.value) { excess = excess - prevbal.value; prevbal.value = 0 ; }
if (excess < secdep.value && amtpaid.value > rentdue.value) { secdep.value = secdep.value - excess; excess = 0}
if (excess >= secdep.value) { excess = excess - secdep.value; secdep.value = 0 ; }
if (excess < damage.value && amtpaid.value > rentdue.value) { damage.value = damage.value - excess; excess = 0}
if (excess >= damage.value) { excess = excess - damage.value; damage.value = 0 ; }
if (excess < latechg.value && amtpaid.value > rentdue.value) { latechg.value = latechg.value - excess; excess = 0}
if (excess >= latechg.value) { excess = excess - latechg.value; latechg.value = 0 ; }
if (excess < courtcost.value && amtpaid.value > rentdue.value) { courtcost.value = courtcost.value - excess; excess = 0}
if (excess >= courtcost.value) { excess = excess - courtcost.value; courtcost.value = 0 ; }
if (excess < nsf.value && amtpaid.value > rentdue.value) { nsf.value = nsf.value - excess; excess = 0}
if (excess >= nsf.value) { excess = excess - nsf.value; nsf.value = 0 ; }
}
</script>
ProgrammingRe: why the unexpected $end by ckdoublene(op): 2:43am On Dec 29, 2010
I'm accessing a database & changing fields in the input before I update the record when I enter the amtpaid. it correctly inserts the date, tentpay, paidsum & the L when the date is greater than 5 but not the prevbal, secdep, damage, latechg, courtcost or nsf. The trouble is that I don't know where/when to use parseInt & .value .

1 2 (of 2 pages)