the below code is intended to update a database file with the no of days late and tax calcs for each record. I'll understand this before I qive up. the subject is the error message.
<?php
$stat = mysql_connect("localhost","root","");
$stat = mysql_select_db("oodb");
$query = "SELECT invnum FROM oocust Where WHERE payrec = 'R' AND pd = ' '";
$stat = mysql_fetch_assoc(mysql_query($query));
echo $stat["invnum"];
$result= mysql_query("select * from oocust");
while($row=mysql_fetch_array($result))
{
$id=$row['id'];
$dayslate=$row['dayslate'];
$charges=$row['charges'];
$duedate=$row['duedate'];
$tax=$row['tax'];
$tax = $charges * .06;
$db = mysql_connect("localhost","root","");
$db = mysql_select_db("oodb");
$query = "SELECT id,charges,datediff(curdate(),duedate) as dayslate, tax FROM oocust Where WHERE payrec = 'R' AND pd = ' '";
$result = mysql_query($query) or die ("could not execute query at line 4");
$days_late = ($row['dayslate'] > 0)?$row['dayslate'] . " days":'N/A';
echo "<p> Charges: " . $stat['charges'] . " Due Date: " . $row['duedate'] . " Late: $days_late Tax: " . $row['tax'] . "</p>";
$sql = "UPDATE oocust SET
tax = '$tax', dayslate = '$dayslate'
WHERE id='$id'";
}
mysql_query($sql) ;
$err=mysql_error();
if($err!=""){
echo "Error in $sql: $err\n";
echo "Invoice Prep completed";
?>