Hi i wanted to select a field called transaction amount in table transaction of debtors , and it does no seem to be able to retrieve the data correctly and i am unable to know how to do casting here is part of the script
//getting values from post/form
$customer = $_POST["customer_id"];
$amount = $_POST["amount_paid"];
$sql = "SELECT tra_outstanding FROM transaction WHERE tra_customer_id='".$customer."'";
$result = nuRunQuery($sql);
$amount_due = db_fetch_object($result);
$amount_due = $amount_due - $amount ;
nuRunQuery("UPDATE transaction SET tra_outstanding =$amount_due WHERE tra_customer_id = '".$customer."'");
please help me out to know how to do the casting
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
SQL CASTING PROBLEM
Re: SQL CASTING PROBLEM
at_rcc,
Try this..
Also, we have a new video on debugging in nuBuilder, that might help you in the future (video 26)
http://www.nubuilder.com/nubuilderwww/i ... ?nav=video
Hope this helps
Steven
Try this..
Code: Select all
$customer = $_POST["customer_id"];
$amount = $_POST["amount_paid"];
$sql = "SELECT tra_outstanding FROM transaction WHERE tra_customer_id = '$customer'";
$result = nuRunQuery($sql); //-- result is a table - even though it might be just 1 row and 1 column
$the_row = db_fetch_object($result); //-- $the_row will be the first row
$amount_due = $the_row->tra_outstanding - $amount ;
nuRunQuery("UPDATE transaction SET tra_outstanding = $amount_due WHERE tra_customer_id = '$customer'");
http://www.nubuilder.com/nubuilderwww/i ... ?nav=video
Hope this helps
Steven
A short post is a good post.