Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    60
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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:
    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
    ]

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •