Hi, please take a look at my code and advise what’s wrong. Following is an error message pertaining to the code that follows:
Update query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE acctno=‘xxx-xxx-xxxx’’ at line 5
following is the php document code
[code]
[/code] [php]<?php // error_reporting(0); error_reporting(E_ALL ^ E_NOTICE); mysql_connect('localhost','root','my_password'); mysql_select_db('homedb') 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 date('m/d/y'); echo "Invoice Payment :amounts | |||||||
---|---|---|---|---|---|---|---|
check# | acct# | Name | Descr | Paid | Due | Date Paid | pd |
Select another?
";} } if(!empty($_POST["update"])) { $sql = "UPDATE oocust SET amtdue = '" . mysql_real_escape_string($_POST['amtdue']) . "', datepaid = '" . mysql_real_escape_string($_POST['datepaid']) . "', pd = '" . mysql_real_escape_string($_POST['pd']) . "', 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]
[/code]
following is the payment.js - the if statement doesn’t work ?
----------------------------------------------------
function $_(IDS) { return document.getElementById(IDS); }
function calculate_paid()
{
var pd = document.getElementById("pd");
var datepaid = document.getElementById("datepaid");
var paidamt = document.getElementById("paidamt");
var amtdue = document.getElementById("amtdue");
var shipamt = document.getElementById("shipamt");
var dateNow = new Date
var dayNow = dateNow.getDate();
var datePaid = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear();
datepaid.value = datePaid;
amtdue.value = parsefloat(amtdue.value) + parsefloat(shipamt.value) - parsefloat(paidamt.value);
// *********************
if (amtdue.value=="0")
{ pd.value = "P"; }
//********************
}