This topic is locked

'Before Record Added' Event Not Working As Expected When Tra

11/10/2007 1:07:45 PM
PHPRunner General questions
W
wblumstengel author

I am currently using:

[indent]PHPRunner 4.1 (Build 320)

MySQL 5.0.27-community-nt

Apache 2.2.4 (Win32) PHP 5.2.4[/indent]

I have sucessfully created a "Before Record Added" event on an Add record page which determines a date in the future one month in advance of the current date. I assign that date to a SESSION variable.

[codebox]// determine a date in the future one month from now

$rs = db_query( "select DATE_ADD(now(),INTERVAL 1 MONTH) as future_date",$conn);

$data = db_fetch_array($rs);

$_SESSION['one_month_from_now'] = $data['future_date'];

[/codebox]

I then use that SESSION variable as the default for a date field visible on an Add record form. When I enter the Add record page, the date field is populated with a date one month in the future, and when I click on the date picker icon next the the field, it defaults to that same date.
This method works fine on my development platform (my PC running XP sp2 running MySQL/Apache/PHP) and I get the expected results when using the date field (and date picker) on my Add record page.
However, when I transfer the web site (I ZIP the website files as built by PHPRunner and copy them over to the other server) to a different server (Window 2003 sp1 running the same versions of MySQL/Apache/PHP as my PC), the date field on my Add record page does not present me with the expected default date of one month in the future. The date field is empty when I enter the Add record page,and the date picker for the field only presents the current date.
I am not sure why this functionality would work on my development PC, but when transferred, would not work on the other server. Everything else about the site works great. I confirmed that the event code is present in the appropriate /include/..events.php file.
Any ideas?

Alexey admin 11/12/2007

Hi,
I don't see anything suspicious in your code.

Try to print out $data array to see your query output.

Use this command:

print_r($data);

W
wblumstengel author 11/19/2007

Everything looked good as far as what was being returned by the array ($data).
I was playing with the default value for the date field, and rather than using a $_SESSION variable, I came up with the following:
date('d/m/Y H:i:s',strtotime('+1 month'))
If I use this as the default value for the date field, I am able to get the field to poplulate with a date 1 month in the future. I do not know why I was having problems using the $_SESSION variable approach, but since this method is working for me, I will go with this instead.