-1

$valid is An array and $createdon and $days are get the Date value from array. My select query is not work with these date value of PHP variable please solve its.

function checkexpiretime($valid)
    {
        $db = &JFactory::getDBO();
        foreach($valid as $validity)
        {
             echo $createdon=$validity->CreatedOn;
             echo $days=$validity->days;
        }
        echo $query="SELECT * FROM jos_generatekey WHERE CreatedOn BETWEEN DATE_ADD('".$createdon."',".INTERVAL $days DAY.")". "AND CURDATE()"; 
        $db->setQuery($query);
        $checkexpire = $db->loadObjectList();
        print_r($checkexpire);
        return $checkexpire;
    }
2
  • possible duplicate of Pass a php variable to mysql query Commented Aug 9, 2012 at 5:54
  • is $valid a multi-dimensional array? Commented Aug 9, 2012 at 5:55

1 Answer 1

0

Query should be like this:

$query= "SELECT * FROM jos_generatekey WHERE CreatedOn BETWEEN DATE_ADD('".$createdon."',INTERVAL ". $days ." DAY) AND CURDATE()";
Sign up to request clarification or add additional context in comments.

1 Comment

$query= "SELECT * FROM jos_generatekey WHERE CreatedOn BETWEEN DATE_ADD('".$createdon."',INTERVAL ". $days ." DAY)"; your query is running but use it with current date function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.