PDA

View Full Version : Help with creating custom error message


kenki
10-05-2009, 06:24 PM
I sent a email to websitedatabases, and they reffered me here, I am hoping someone can help.

I wrote the following piece of code for my reservation database. This code sits just above the insert sql statement.
It works as expected, if someone enters a reservation for more than 7 days, the entry does not go in to the database.

What I need to do is create an error message in the detail view or the table view. Note the print statement, all that does is flash for a split second as the page refreshes.

Can someone help me with how to display this message after the page refreshes after the user has clicked add new or update?



// Do not allow reservations over 7 days.

$days = abs(strtotime($frdate) - strtotime($todate)) / (60 * 60 * 24);

if ($days > 7) return;

else;

{ print '<p> You cannot reserve an item for more than 7 days</p>';

}


Thanks

Ken.

Lana
10-06-2009, 03:04 PM
set a time limit (3) seconds for example

<?php
set_time_limit(3);
?>

kenki
10-07-2009, 12:45 PM
Thanks for your reply, unfourtunately this does not work. I still see the error message flash quickly. I believe this is due to the refresh of the template.

I will continue to work on this, and if I find a working solution I will post it.

Ken.

Lana
10-07-2009, 05:33 PM
Backup your original file and try this...

$days = abs(strtotime($frdate) - strtotime($todate)) / (60 * 60 * 24);

if ($days > 7);
{ print '<p> You cannot reserve an item for more than 7 days</p>';

}
// sleep for 8 seconds
sleep(8);

return;

:)