how to pass the php variable in Mysql select Query
<p><code>$valid</code> is An array and <code>$createdon</code> and <code>$days</code> are get the Date value from array.
 My select query is not work with these date value of <code>PHP</code> variable please solve its.</p>

<pre><code>function checkexpiretime($valid)
    {
        $db = &amp;JFactory::getDBO();
        foreach($valid as $validity)
        {
             echo $createdon=$validity-&gt;CreatedOn;
             echo $days=$validity-&gt;days;
        }
        echo $query="SELECT * FROM jos_generatekey WHERE CreatedOn BETWEEN DATE_ADD('".$createdon."',".INTERVAL $days DAY.")". "AND CURDATE()"; 
        $db-&gt;setQuery($query);
        $checkexpire = $db-&gt;loadObjectList();
        print_r($checkexpire);
        return $checkexpire;
    }
</code></pre>
