...

View Full Version : why do I get the message "unexpected $end"?



ckdoublenecks
01-02-2011, 01:13 AM
I'm sorry but I'm still learning and don't understand why the message "unexpected $end" pointing to my last code line?


<?php
mysql_connect(localhost,root,"");
mysql_select_db(test) or die( "Unable to select database");
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") {$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.");
echo "Records have been updated";
?>
</script></head></html>

Nile
01-02-2011, 01:16 AM
<?php
mysql_connect(localhost,root,"");
mysql_select_db(test) or die( "Unable to select database");
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") {$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.");
echo "Records have been updated";
}
?>
</script></head></html>

ckdoublenecks
01-02-2011, 03:35 AM
thanks for the help. You were right but the " was in the wrong place. Now no error but no update either?

Nile
01-02-2011, 04:50 AM
Try fixing:


mysql_connect("localhost","root","");
mysql_select_db("test") or die( "Unable to select database");
But I dont know, if you're not actually getting an error and the above doesn't work, post in the mysql forum

ckdoublenecks
01-02-2011, 05:17 AM
I fixed the error by adding a " to OR late = 'L')";. the code is now


<?php
mysql_connect("localhost","root","");
mysql_select_db("test") or die( "Unable to select database");
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") {$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')";
mysql_query($sql) or die("Update query failed.");
echo "Records have been updated";
}
}
?>

<head></html>
it does not update

Nile
01-02-2011, 05:23 AM
<?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')";
mysql_query($sql) or die("Update query failed.");
echo "Records have been updated";
}
}
?>

Get rid of that parenthesis

ckdoublenecks
01-02-2011, 09:17 PM
My big doubt has always been - how do I state the variables in the javascript so that it works with the php?

Nile
01-03-2011, 04:40 AM
You need to use ajax for something like that



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum