skip to Main Content

This the code, I keep getting the error function not define but Im attempting to retrieve the data from mysql. This code was working with an older version on PHP.

$date1 = $_GET['date1'];
$date2 = $_GET['date2'];

if (validateDate($date1){
    $date1status = true;
} else {
    $date1status = false;
}

if (validateDate($date2){
    $date2status = true;
} else {
    $date2status = false;
}

$bywho = $_GET['bywho'];
if (!empty($bywho) {
    $whostatus = true;
} else {
    $whostatus = false;
}

$programfilter = $_GET['programfilter'];

if ($programfilter == '') {
    $programfilterstatus = false;
} else {
    $programfilterstatus = true;
}

2

Answers


  1. Less code

    $date1status=validateDate( $_GET['date1']) ?  true :false;
    
    $date2status=$date2 =validateDate( $_GET['date2']) ?  true :false;
    
    $whostatus=$_GET['bywho']   ? true : false;
    
    $programfilter = $_GET['programfilter'] ?  true :false;
    
    Login or Signup to reply.
  2. I’m going to go out on a limb here and assume your validateDate() method is not defined, and since its not part of the PHP library, you’re getting the error.

    checkdate() is part of the php library however. If you’re just trying to validate a date in gregorian format then checkdate() is what you should use

    https://www.php.net/manual/en/function.checkdate.php

    $date1 = $_GET['date1'];
    $date2 = $_GET['date2'];
    
    if (checkdate($date1){
        $date1status = true;
    } else {
        $date1status = false;
    }
    
    if (checkdate($date2){
        $date2status = true;
    } else {
        $date2status = false;
    }
    
    $bywho = $_GET['bywho'];
    if (!empty($bywho) {
        $whostatus = true;
    } else {
        $whostatus = false;
    }
    
    $programfilter = $_GET['programfilter'];
    
    if ($programfilter == '') {
        $programfilterstatus = false;
    } else {
        $programfilterstatus = true;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search