This topic is locked
[SOLVED]

 Undefined variable key error thrown on add pages

6/13/2014 11:47:32 AM
PHPRunner General questions
S
Sir3James author

Hi, I'm using PHPRunner 6.0 (Build 9948) to update a project originally developed with PHPRunner 5.X (Build XXXX). I'm trying to implement the Audit Trail feature and on every add page, right after I click the save button, I keep receiving the PHP error "Undefined variable: key" found on line 589 of "/include/audit.php" (before I enabled the Audit Trail feature, the save feature functioned as expected)
I've done some digging in audit.php and I see that the $key variable is dependent on the $keys array which is passed into the LogAdd() function. (also, I noticed there are two LogAdd() functions in audit.php, the second of which is the one being used, why is that?) The only pages using the LogAdd() function are xxxx_add.php pages and I can see they're all creating a $keys array, the problem is, the $keys array doesn't seem to be getting properly populated.
Thanks, and let me know if you need more clarification.

Admin 6/13/2014

I'm not quite sure I understand. Are you talking about built-in audit functionality or about some code you have added manually to events like AfterAdd?

S
Sir3James author 6/13/2014

Yes, I'm refering to PHPRunner's built-in Audit Trail feature.

A file called audit.php is generated in the include folder and I have no control over the code inside of this file.

I have noticed that the aforementioned $keys array passed to the LogAdd() function of the audit.php page is always empty.

All add pages use the LogAdd() function, and it is in these xxxx_add.php files that the $keys array is declared and it appears the array isn't being populated correctly.

(I have tried commenting out all custom code in the "Before display" and "After record added" to eliminate error on my part but I got the same result, that is: "Undefined variable: key")

Admin 6/13/2014

Just in case make sure that all your custom code is removed. If this still doesn't help 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.

S
Sir3James author 6/19/2014

I found that the "Undefined variable key" error only happens if you apply the audit trail feature to a view.

By their nature, a view isn't really meant to be edited anyways, so enabling that option was a mistake on my part.