Hi,
I have 2 tables "Purchase" and "Invoices" , link fields are ControlNo
and AControlno
.
Invoices has 2 fields Paid
and Rate
. Purchase has Totalpaid
.
I want to sum up (Paid * Rate) into Totalpaid
, where ControlNo
and AControlno
are same.
global $conn;
$str = "select sum(`paid` * `rate`) from invoices where Acontrolno = '{$values["controlno"]}'";
$rs = db_query($str,$conn);
$data = db_fetch_numarray($rs);
$ttl=$data[0];
$strUpdate = "update purchase set `totalpaid`= '{$ttl}' where controlno = '{$values["controlno"]}'";
db_exec($strUpdate,$conn);
I Get following error:
PHP error happened
Technical information
Error type 256
Error description 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 ControlNo=123/23' at line 1
URL localhost/PHPRunner/invoices_edit.php?
Error file C:\Documents and Settings\Administrator\Desktop\mowes_portable\www\accounts\output\include\dbconnection.php
Error line 34
SQL query Update purchase set TotalPaid= where ControlNo=123/23
Solution
This is a general error. It occurs when there is an error in event code or in SQL.
The Purchase
table is also not getting update.
Please help.
B.