prince198 Posted July 10, 2008 Share Posted July 10, 2008 hi every body first thak you for people helping me for function like to_days() in my sql so i have this script $nbrdays[ ] = 0; $To_days_start=to_days('2008-01-01'); $To_days_end=to_days('2008-03-03'); $Get_week =date('W',strtotime('2008-01-01')); $week= trim($Get_week, 0); $day_week=date('N',strtotime('2008-01-01')); for( $day = $To_days_start; $jour <= $To_days_end; $day++ ) { if( $day_week >= 1 AND$day_week < 7 ) $nbrdays[$week-1]++; $day_week++; if( $day_week > 7 ) { $week++; $day_week= 1; } } print_r($nbrdays) and i have result that i'm looking for :number day by week without sunday Array ( [0] => 5 [1] => 6 [2] => 6 [3] => 6 [4] => 6 [5] => 6 [6] => 6 [7] => 6 [8] => 6 [9] => 1 ) but with this errors Notice: Undefined offset: 1 in..... Notice: Undefined offset: 2 in .. Notice: Undefined offset: 3 in .. Notice: Undefined offset: 4 in .. Notice: Undefined offset: 5 ... i don't understand why i have errors although that i have now the result that i'm looking for Link to comment https://forums.phpfreaks.com/topic/114065-solved-my-script-work-but-some-errors-is-displayed/ Share on other sites More sharing options...
rmbarnes82 Posted July 10, 2008 Share Posted July 10, 2008 You'll get a reply quicker if you print the full error messages, and tell us which line in your code sample they relate to. Link to comment https://forums.phpfreaks.com/topic/114065-solved-my-script-work-but-some-errors-is-displayed/#findComment-586256 Share on other sites More sharing options...
the shig Posted July 10, 2008 Share Posted July 10, 2008 hi, you're incrementing an array value when the index is not set. change <?php $nbrdays[$week-1]++; ?> to <?php if(!isset($nbrdays[$week-1])) { $nbrdays[$week - 1] = 0; } $nbrdays[$week-1]++; ?> should fix it. make sure you put curly brackets { } after your conditional statements. Link to comment https://forums.phpfreaks.com/topic/114065-solved-my-script-work-but-some-errors-is-displayed/#findComment-586259 Share on other sites More sharing options...
prince198 Posted July 10, 2008 Author Share Posted July 10, 2008 thank you for helping it's work!!! but a finf this function :error_reporting(E_ALL ^ E_NOTICE); this function don't show notice errors in php Link to comment https://forums.phpfreaks.com/topic/114065-solved-my-script-work-but-some-errors-is-displayed/#findComment-586285 Share on other sites More sharing options...
trq Posted July 10, 2008 Share Posted July 10, 2008 You might need to enable display_errors as well. ini_set('display_errors','1') Link to comment https://forums.phpfreaks.com/topic/114065-solved-my-script-work-but-some-errors-is-displayed/#findComment-586287 Share on other sites More sharing options...
prince198 Posted July 10, 2008 Author Share Posted July 10, 2008 yes but i think i will use the solution of the shig because i need to show my errors for otheres pages Link to comment https://forums.phpfreaks.com/topic/114065-solved-my-script-work-but-some-errors-is-displayed/#findComment-586290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.