This topic is locked

Problem with $keys in AfterAdd Event

1/29/2008 1:34:01 PM
PHPRunner General questions
Microe author

Hi
I am trying to us an AfterAdd Event to redirect from a Master Table (_Clients) to a Detail Table List page (_WaitList) so that I can perform an add of detail records immediately. The code I am using is:
function AfterAdd(&$values,&$keys,$inline)

{

// Parameters:

// $values - Array object.

// Each field on the Add form is represented as a 'Field name'-'Field value' pair

// $keys - Array object with added record key column values
//{ Redirect to another page ****

header("Location: _WaitLog_list.php?mastertable=_Clients&masterkey1=".$keys["iWaitlistID"]);

exit();

}
where iWaitlistID is the Auto-increment Primary Key in _Clients that relates to the details table.
.$keys["iWaitListID"] returns nothing. I have checked the $keys array using print_r($keys) and it show nothing.
Any clues?
Thanks,

Mike

Sergey Kornilov admin 1/29/2008

Mike,
please post your application to Demo Account and send the URL to support@xlinesoft.com.

Microe author 1/29/2008

Mike,

please post your application to Demo Account and send the URL to support@xlinesoft.com.



I uploaded the Project to the Demo Account but I got this error..


The project is at http://demo.asprunner.net/microe_eng_hotma...nline/login.php
Thanks for you help,

Mike

J
Jane 1/30/2008

Mike,
please zip and send to [email=support@xlinesoft.com]support@xlinesoft.com[/email] a full set of generated PHP files, your database creation script with sample data and project file for investigation.

I'll find what's wrong with your project running it on my test box.

Microe author 1/31/2008

I tried what you sent me Jane and it didn't work. I think that is because the AutoIncremented Value is not set in the event session, but by the database itself outside the session and thus is not included in the original query. After playing around I found that the code below works:
header("Location: _WaitLog_list.php?mastertable=_Clients&masterkey1=".mysql_insert_id());

exit();
Thanks,

Mike