Hello I am using mktime in my code and get this warning: Warning: mktime() expects parameter 1 to be long, string given in (file_address.php) on line 329 This is the code: $tmpDate = date('Y-m-d H:m:s'); $query="SELECT * FROM res_restaurents WHERE user_id='".$_SESSION['userId']."' order by iD desc"; $q=mysql_query($query); while($row_list = mysql_fetch_array($q)) { $insertime=$row_list['dateCreated']; } $date1 = time(); $dat = explode(" ",$insertime); $tmpDate = explode("-", $dat[0]); $tmpTime = explode(":", $dat[1]); //echo "jj".$tmpTime[0]."jj"; $date2 = mktime($tmpTime[0],$tmpTime[1],$tmpTime[2],$tmpDate[1],$tmpDate[2],$tmpDate[0]); $dateDiff = $date1 - $date2; $fullMinutes = floor(($dateDiff-($fullDays*60*60*24)-($fullHours*60*60))/60); $query = "SELECT minutes FROM user_register WHERE id='$user_id'"; $q2=mysql_query($query) or die(mysql_error()); $minutes=mysql_fetch_array($q2); PHP: How can I fix it? Thanks for your help
Just above, try something like this: $tmpTime = array_map("floatval", $tmpTime); $tmpDate = array_map("floatval", $tmpDate); PHP: If that doesn't work you might want to use var_dump to see exactly what data is stored in the array.
There is a nice function called strtotime which I would use here. try something like this $tmpDate = date('Y-m-d H:m:s'); $query="SELECT * FROM res_restaurents WHERE user_id='".$_SESSION['userId']."' order by iD desc"; $q=mysql_query($query); while($row_list = mysql_fetch_array($q)) { $insertime=$row_list['dateCreated']; } $date1 = time(); $date2 = strtotime($insertime); $dateDiff = $date1 - $date2; $fullMinutes = floor(($dateDiff-($fullDays*60*60*24)-($fullHours*60*60))/60); $query = "SELECT minutes FROM user_register WHERE id='$user_id'"; $q2=mysql_query($query) or die(mysql_error()); $minutes=mysql_fetch_array($q2); PHP: