This topic is locked

Troubleshoot an After Add event

11/6/2013 1:52:10 PM
PHPRunner General questions
S
sgchan author

I have a Master - Detail (tbl_personal - tbl_disbursement) and have the below code in the tbl_personal After Add event:
global $conn;

$strSQL_totalGrant = "SELECT (SUM(amount1) + SUM(amount2) + SUM(amount3)) AS totalGrant FROM tbl_disbursement WHERE (tbl_personal_id = '".$keys["id"]."') AND (type = '0000000001')";

$strSQL_totalLoan = "SELECT (SUM(amount1) + SUM(amount2) + SUM(amount3)) AS totalLoan FROM tbl_disbursement WHERE (tbl_personal_id = '".$keys["id"]."') AND (type = '0000000002')";
$dataGrant = db_fetch_array(db_query($strSQL_totalGrant,$conn));

$dataLoan = db_fetch_array(db_query($strSQL_totalLoan,$conn));
$strSQL_total = "UPDATE tbl_personal SET total_grant_committment = '".$dataGrant["totalGrant"]."', total_loan_committment = '".$dataLoan["totalLoan"]."' WHERE id='".$keys["id"]."'";
echo "<script> alert('". $strSQL_total. "'); </script>";
$db_exec($strSQL_total, $conn);

The code isn't not doing what it is intended. My question is how do you trouble shoot the code? The page switches into new Add screen whenever I save. I have tried using ECHO and Javascript ALERT but neither would show. Hence I am unable to see what is happening.
Could someone provide some advice? Many thanks in advance.
P.s. - I am using PHPR 6.2

Sergey Kornilov admin 11/6/2013

Use echo statement and then exit(); i.e.

echo $strSQL;

exit();
S
sgchan author 11/6/2013


echo $strSQL;

exit();



Thanks for the reply. I tried that but it didn't work. Also tried "die".
After saving the program still switched to a new Add record. Anyway of stopping it from moving to a new Add record?

Sergey Kornilov admin 11/7/2013

I'm afraid you doing something wrong i.e. adding this code to the wrong place. It works as expected on test project.

S
sgchan author 11/7/2013



I'm afraid you doing something wrong i.e. adding this code to the wrong place. It works as expected on test project.


Hmm... I have removed all code in the After Add event except

Echo "What is wrong";

exit();



It has totally ignored that code... as though the event is totally ignored. Any advice on how I can trouble shoot?

Sergey Kornilov admin 11/7/2013

If you have a valid support contract post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program. Someone will take a look and find what is wrong.
PS. Echo must be echo, case-sensitive.