zoonose Posted February 28, 2008 Share Posted February 28, 2008 I am trying to recover a multidimensional array with the following code, however, it doesn't seem to be working! If i replace $query_date with a numerical (unix timestamp) i.e '1204894800' - it works a treat. i cannot understand why it wont work with a variable? 1. $date = mktime(0,0,0,date('m'), date('d'), date('Y')); 2. $day = date('d', $date); 3. $month = date('m', $date); 4. $year = date('Y', $date); 5. 6. $SelMthDays = cal_days_in_month(0, $month, $year); 7. echo $SelMthDays; 8. $Palm_events = array(); 9. for ($i=1;$i<=$SelMthDays;$i++){ 10. $query_date = mktime(0,0,0,$month,$i,$year); 11. $sql = "SELECT e_family FROM `dates` WHERE e_date = $query_date"; 12. $result = mysql_query($sql,$con); 13. $Palm_events[$i] = mysql_fetch_row($result); 14. 15. } 16. 17. print_r($Palm_events); Link to comment https://forums.phpfreaks.com/topic/93584-can-anyone-help-with-this-mysql-query/ Share on other sites More sharing options...
premiso Posted February 28, 2008 Share Posted February 28, 2008 You could try this for $query_date $query_date = strtotime($i . '-' . $month . '-' . $year); Which converts a textual date to a unix timestamp. Link to comment https://forums.phpfreaks.com/topic/93584-can-anyone-help-with-this-mysql-query/#findComment-479585 Share on other sites More sharing options...
zoonose Posted March 2, 2008 Author Share Posted March 2, 2008 Problem was my zend studio is on my computer and in a different timezone to the server. script works a treat on the server!! thanks for your help! Link to comment https://forums.phpfreaks.com/topic/93584-can-anyone-help-with-this-mysql-query/#findComment-481564 Share on other sites More sharing options...
monkeybidz Posted March 2, 2008 Share Posted March 2, 2008 <?php 11. $sql = "SELECT e_family FROM `dates` WHERE e_date = '$query_date' "; ?> Link to comment https://forums.phpfreaks.com/topic/93584-can-anyone-help-with-this-mysql-query/#findComment-481570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.