This topic is locked

Adding own functions via login events

10/26/2007 02:12:49
PHPRunner General questions
G
giles author

Hi,

I have some php code activated via events that in need to use in 7 places in a project. I'm trying to put the code in a function in the loginonload event and just can't seem to get it working....



Here's what apears in the loginonload event...
function LoginOnLoad(&$params)

{
// Put LoginOnLoad code here.
}
//****
Insert project specific functions here ****
function recalcoverallquoteprice()

{

global $conn;

$strSQL = "select sum(`Final exc Seals SWT Init`) as FullQuoteInitBase from facilities where ServiceID=".$_SESSION["ServiceID"];

$rs = db_query($strSQL,$conn);

$data=db_fetch_array($rs);

$strSQLUpdate = "Update services set `Full Quote Init Base`=".$data["FullQuoteInitBase"]." where ServiceID=".$_SESSION["ServiceID"];

db_exec($strSQLUpdate,$conn);
} // function LoginOnLoad
I'm calling this via an edit page after record updated event using as follows:
recalcoverallquoteprice()
The code works fine if I just insert it into the after record updated event (without the function line) so I know the code does the job. But if I try to use the function then I get a
"syntax error, unexpected {"** as soon as I try to bring up the edit page.
What am I doing wrong here? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=6626&image=1&table=forumtopics' class='bbc_emoticon' alt=':blink:' />

Alexey admin 10/26/2007

Hi,
your code looks correct.
The "syntax error" message displays a file name and a line number where the error is found.

Inspect that file and line to find the error.

G
giles author 10/26/2007

Thanx Alexey,

Once you confirmed the code in the function declaration was correct I knew the error was elsewhere.
In this case obvious... no ";" at the end of the function call in the other events... as in recalcoverallquoteprice();
Damn, lost a couple of hours on such a simple thing...