Forums

PHP help

olaeblue 25 Nov, 2011
Working on from my previous post. http://www.chronoengine.com/forums.html?cont=posts&f=26&t=23095 I am now adding a check to confirm the date is not too far in the future.

Everything works fine except the validation message which I want to say
"We can not accept bookings after 2012-12-31."
or
"We can not accept bookings after 31 Dec 2012."

but using the code below the date value '$d' is just ignored giving "We can not accept bookings after ."

any ideas, what my stupid error is?

    $db =& JFactory::getDBO();
    $query = "
      SELECT `latestdate`
        FROM `#__chronoforms_data_HutBookingLimit`
        WHERE `cf_user_id` = '90e7227465f69bf8ec01acc5f8c17c52' ;
    ";
    $db->setQuery($query);
    $d = $db->loadResult();
if($from_date > $d)
{
$error_count++;
$form->validation_errors['from_date'] = "We can not yet accept bookings after " . $d. ".";}
GreyHead 25 Nov, 2011
Hi olaeblue,

Check the query with PHPMyAdmin - I don't think that that is a valid entry for cf_user_id so the query will return an empty string.

Bob
olaeblue 25 Nov, 2011
it should be cf_uid your right, but now realised that the form that sets the date isn't updating the same record, but creating a new one. How can I force DB Save to to update the record that was loaded not save as a new record??

Sorted. Use cf_uid to lookup & add hidden field to form called cf_id to save back same record (RTFM 😀 ).
This topic is locked and no more replies can be posted.