This topic is locked
[SOLVED]

 now()

7/1/2011 12:52:16 PM
PHPRunner General questions
bbarker author

I'm trying to get this to work as an EVENT,

but get an error on the third line.

Parse error: syntax error, unexpected T_STRING


global $conn, $strTableName;

if ($_SESSION[$strTableName."_masterkey1"]){

$strSQLUpdate = "UPDATE tblvendors SET LastActivity = "now()"

WHERE VendorID = ".$_SESSION[$strTableName."_masterkey1"];

db_exec($strSQLUpdate,$conn);


Any ideas?

C
cgphp 7/1/2011
global $conn, $strTableName;

if ($_SESSION[$strTableName."_masterkey1"]){

$strSQLUpdate = "UPDATE tblvendors SET LastActivity = '".now()."' WHERE VendorID = ".$_SESSION[$strTableName."_masterkey1"];

db_exec($strSQLUpdate,$conn);
bbarker author 7/1/2011

Thanks...

When I add it, I get this error pointing to the last line of the EVENT file.

Parse error: syntax error, unexpected ';', expecting T_FUNCTION


I have 3 Events in that location. Is the "{" shown once, enough?

Example:
function BeforeMoveNextList(&$data,&$row,&$record)

{

Event 1
Event 2
Event 3

}

C
cgphp 7/1/2011

The closing bracket is missing.

global $conn, $strTableName;

if ($_SESSION[$strTableName."_masterkey1"])

{

$strSQLUpdate = "UPDATE tblvendors SET LastActivity = '".now()."' WHERE VendorID = ".$_SESSION[$strTableName."_masterkey1"];

db_exec($strSQLUpdate,$conn);

}
bbarker author 7/1/2011

I'm so close... no errors now, but it still doesn't work.

Is there something about my brackets on the three events that is causing the THIRD EVENT to NOT work?

(Thanks in advance for ALL of your help. This is the very last thing that I need to fix before we enter the first 1,000 records!)
Example:



function BeforeMoveNextList(&$data,&$row,&$record)

{

// FIRST EVENT - function Save Last Stall year into database

if ($data["VendorID"])

$query = "SELECT MAX(Year) FROM tblstalls WHERE VendorID = ". $data["VendorID"];

$result = mysql_query($query) or die("Query failed with error: ".mysql_error());

$datatmp=db_fetch_array($result);

$record["LastStall_value"] = $datatmp['MAX(Year)'];
// SECOND EVENT - function update PREPAID checkbox after Stall MODIFIED

global $conn, $strTableName;

if ($_SESSION[$strTableName."_masterkey1"])

{

$strSQLUpdate = "UPDATE tblvendors SET Prepaid = ".$_SESSION["Prepaid"]."

WHERE VendorID = ".$_SESSION[$strTableName."_masterkey1"];

db_exec($strSQLUpdate,$conn);

}
// THIRD EVENT - function update LASTACTIVITY in tblVendor after Stall MODIFIED

global $conn, $strTableName;

if ($_SESSION[$strTableName."_masterkey1"])

{

$strSQLUpdate = "UPDATE tblvendors SET LastActivity = '".now()."'

WHERE VendorID = ".$_SESSION[$strTableName."_masterkey1"];

db_exec($strSQLUpdate,$conn);

}
// After Record Processed

//TheEnd

;

} // function BeforeMoveNextList
C
cgphp 7/1/2011

You don't need the function declaration

function BeforeMoveNextList(&$data,&$row,&$record)



It is already added by PHP runner. What you have to paste inside the white area is the following code:

global $conn, $strTableName;
// FIRST EVENT - function Save Last Stall year into database

if ($data["VendorID"])

{

$query = "SELECT MAX(Year) FROM tblstalls WHERE VendorID = ". $data["VendorID"];

$result = mysql_query($query) or die("Query failed with error: ".mysql_error());

$datatmp=db_fetch_array($result);

$record["LastStall_value"] = $datatmp['MAX(Year)'];

}
if ($_SESSION[$strTableName."_masterkey1"])

{

// SECOND EVENT - function update PREPAID checkbox after Stall MODIFIED

$strSQLUpdate = "UPDATE tblvendors SET Prepaid = ".$_SESSION["Prepaid"]." WHERE VendorID = ".$_SESSION[$strTableName."_masterkey1"];

db_exec($strSQLUpdate,$conn);
// THIRD EVENT - function update LASTACTIVITY in tblVendor after Stall MODIFIED

$strSQLUpdate = "UPDATE tblvendors SET LastActivity = '".now()."' WHERE VendorID = ".$_SESSION[$strTableName."_masterkey1"];

db_exec($strSQLUpdate,$conn);

}



I have arranged it in a different manner.

bbarker author 7/1/2011

Events 1 and 2 worked.

3 does not.
I just looked and "LastActivity" field type is "datetime".

Would that be preventing it from being updated by "now()"?

C
cgphp 7/1/2011

Check inside phpmyadmin if the LastActivity field was updated.

Probably it's only a view issue. You have to set LastActivity field in PHPrunner to be viewed as "Datetime".
http://xlinesoft.com/phprunner/docs/_view_as__settings_custom.htm

bbarker author 7/1/2011

Nope... that didn't do it.
Previously was SHORTDATE, and it displayed as:

4/11/2011
I changed it to DATETIME, and it now displays:

4/11/2011 12:12:25 PM
The full date/time value is stored okay in the database per myPHPadmin.
The SECOND and THIRD events are almost identical. The Second one works, and the Third one doesn't.
Any more ideas?? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=59165&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />

  1. Is it because the field is READONLY in the PHPR properties?
    Note: The date/time saves correctly to LastActivity,

    when I ADD a vendor, but NOT when I EDIT one!!!!!!

C
cgphp 7/1/2011

If the LastActivity field is readonly you can't update it. Change it to a text field.

bbarker author 7/1/2011

Well... the reason why it is "readonly" is so that the USER can't modify it. It is for "display" only. It is the "timestamp" of when the record was last updated.
There has to be other people who have a similar arrangement - with a timestamp that they want to update when triggered by different events.
I'll keep looking at this. I thought that the following CLUE that I found was interesting.

... The date/time saves correctly to "LastActivity",

when I ADD a vendor,

but NOT when I EDIT one!!!!!!

C
cgphp 7/2/2011

Bill B,
post a minimal demo of your project.

bbarker author 7/2/2011



post a minimal demo of your project.



Last night I saved a copy of it to the DEMO account. Hopefully the XLINESOFT folks will figure out why the event isn't working.

bbarker author 7/3/2011

Hopefully someone isn't looking for the solution here. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=59196&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />
I have closed my HELP TICKET.

This took too much trouble-shooting to resolve.
I've read the manual, but it's still unclear to me exactly WHEN each Event actually takes place - and what the various "nuances" are. Maybe the new WIKI that is going to be deployed will help by allowing people to add additional tips and hints.
I added the "now()" code to the php page and have removed the EVENT functions.
Database Updates now work as desired. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=59196&image=2&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />