Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-26-2013, 05:02 PM   PM User | #1
ckdoublenecks
New Coder

 
Join Date: Jun 2010
Posts: 60
Thanks: 4
Thanked 0 Times in 0 Posts
ckdoublenecks is an unknown quantity at this point
need help with code

this code worked for a long tome but in an effort to modify I got lost and need some direction.below are the error message and the code:
Quote:
Parse error: syntax error, unexpected 'calculate_paid' (T_STRING), expecting ',' or ';' in C:\xampp\htdocs\invoice\payment.php on line 63
[CODE]
Code:
<html><head>
<!--when the paidamt is keyed in, the current date,& baldue are autoinserted-->
<script>
function $_(IDS) { return document.getElementById(IDS); }
function calculate_paid() {
   var paidamt = document.getElementById("paidamt");
     var amtdue = document.getElementById("amtdue");
 var datepaid = document.getElementById("datepaid");
                           var dateNow = new Date();   
                     var dayNow = dateNow.getDate();   
var datePaid = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear();
            datepaid.value = datePaid;
amtdue.value = parseint(amtdue.value);
if(amtdue > 0.00) 
{ 
amtdue.value = parseint(amtdue.value) - parseint(paidamt.value);
}
</script>
<script type="text/javascript">
window.google_analytics_uacct = "UA-256751-2";
</script>
<script type="text/javascript">
window.google_analytics_uacct = "UA-256751-2";
</script></head><body>
[PHP]<?php
// error_reporting(0);
error_reporting(E_ALL ^ E_NOTICE);
mysql_connect('localhost','root','');
mysql_select_db('oodb') or die( "Unable to select database");
if(!empty($_POST["submit"]))
{
$acctno = $_POST['acctno'];
$query="SELECT * FROM oocust Where acctno='$acctno'";
$result=mysql_query($query);
if(mysql_num_rows($result))
{
echo "<form action='#' method='post'>Invoice Payment :<br /><br />
<table cellspacing=0 cellpadding=0 border=1>;
<tr>
<th>acctno</th>
<th>Name</th>
<th>Description</th>
<th>checkno</th>
<th>Paid Amt</th>
<th>Date Paid</th>
<th>Amt Due</th>
"</tr>
while($row = mysql_fetch_assoc($result))
{
echo "<tr>
<td><input type='text' size=25 name='acctno' 'value='" . $row['acctno'] . "'></td>
<td><input type='text' size=25 name='bname' value='" . $row['bname'] . "'></td>
<td><input type='text' size=25 name='descr' value='" . $row['descr'] . "'></td>
<td><input type='text' size=5 name='checkno' value='" . $row['checkno'] . "'></td>
<td><input type='text' size=25 id='paidamt' name='paidamt' value='" .
$row['paidamt'] ."'
onBlur='calculate_paid(this)'></td>
<td><input type='text' id='datepaid' size=7 name='datepaid' value='" .
$row['datepaid'] . "'></td>
<td><input type='text' id='amtdue' size=25 name='amtdue' value='" . $row['amtdue'] . "'></td>
</tr>";
}
echo </table>";
<input type="submit" name="update" value="Make Payment" />
</form>";
}
else{echo "No listing for account no. $acctno.<br />Please select another.<br />";}
}
if(isset($_POST["update"]))
{
$sql = "UPDATE oocust SET
datepaid = '" . mysql_real_escape_string($_POST['datepaid']) . "',
paidamt = '" . mysql_real_escape_string($_POST['paidamt']) . "',
amtdue = '" . mysql_real_escape_string($_POST['amtdue']) . "',
WHERE acctno='".$_POST["acctno"]."'";
mysql_query($sql) or die("Update query failed: " . mysql_error());
echo "Record for acct# ".$_POST["acctno"]." has been updated";
}
?>[/PHP
Code:
]<form method="post" action="#">
<br />
<input type="text" name="acctno"/> <p>
<input type="submit" name="submit" value="select acct#."/>
</form>
<script type="text/javascript"><!--
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
//-->
</script>
<script type="text/javascript"><!--
try {
var pageTracker = _gat._getTracker("UA-256751-2");
pageTracker._trackPageview();
} catch(err) {}
//-->
</script>
<script type="text/javascript"><!--
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
//-->
</script>
<script type="text/javascript"><!--
try {
var pageTracker = _gat._getTracker("UA-256751-2");
pageTracker._trackPageview();
} catch(err) {}
//-->
</script>
</body></html>[/CODE
]
ckdoublenecks is offline   Reply With Quote
Old 01-26-2013, 05:33 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Always use just the php code tags since it's what highlights the strings. Works on most C based languages as well so the JS would also get markup. That said, the JS is also completely irrelevant to the PHP code, so that can safely be removed completely from your posts.
PHP Code:
echo "<form action='#' method='post'>Invoice Payment :<br /><br />
<table cellspacing=0 cellpadding=0 border=1>;
<tr>
<th>acctno</th>
<th>Name</th>
<th>Description</th>
<th>checkno</th>
<th>Paid Amt</th>
<th>Date Paid</th>
<th>Amt Due</th>
"
</tr
That's butchered. You shouldn't have made it as far as you did, meaning you've either something different than what is here, or you've lost something but not wrapping it in the code/php blocks.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:37 AM.


Advertisement
Log in to turn off these ads.