DazlerD Posted April 27, 2007 Share Posted April 27, 2007 I have a diary entry web site that was running on a Windows server. It is now being hosted on a Linux server. I have fixed most of the errors (Using variables before declaring them) but there is one I cant solve. My code find the start of the week and creates a 2 dimensional array. The 1st dimension is the date and within each date we have the hours 0 to 23. // Setup Date Array for ($wd = 0; $wd < 7; $wd++) { $col_name = date('dmY', mktime(0, 0, 0, date("m",$StartOfWeek) , date("d",$StartOfWeek)+$wd, date("Y",$StartOfWeek))); echo '<br>'.$col_name; $a_diary = array($col_name => array("00" => "", "01" => "", "02" => "", "03" => "", "04" => "", "05" => "", "06" => "", "07" => "", "08" => "", "09" => "", "10" => "", "11" => "", "12" => "", "13" => "", "14" => "", "15" => "", "16" => "", "17" => "", "18" => "", "19" => "", "20" => "", "21" => "", "22" => "", "23" => "")); } This produces: 22042007 23042007 24042007 25042007 26042007 27042007 28042007 Then I retrieve all diary entries from the diary table for the logged in user. As I loop through these diary entries I try to add the values to the relevant position in the array. // getting the diary entry values into the a_diary array while ($row = mysql_fetch_array($result)) { $ro = date("dmY",strtotime($row[1])); // Date $co = date("H",strtotime($row[2])); // Time $a_diary[date($ro)][$co] .= '<a href="editdate.php?di=' . $row[0] . '"><img src="images/play.gif" border="0" alt="edit event"></a> ' . $row[3] . ' @ ' . $store_names[$row[4]]; } This gives me an error of: Notice: Undefined index: 12 in /home/fhlinux444/f/mydomain.co.uk/user/htdocs/domain/date.php on line 277 which after adding in loads of 'echo' statements means it cant get the element of: $a_diary[date($ro)][$co]. If I echo the date($ro) and $co i get: 27042007 12 Notice: Undefined index: 27042007 Im looking for a element which has been created, Im confused !! It worked fine on Windows server. Anybody any ideas please? Thanks Darren Quote Link to comment Share on other sites More sharing options...
taith Posted April 27, 2007 Share Posted April 27, 2007 why are you doing date($ro)? the $ro already holds a date... Quote Link to comment Share on other sites More sharing options...
DazlerD Posted April 27, 2007 Author Share Posted April 27, 2007 I thought that I must admit, but I didnt write this part and the bloke who wrote it has years of experience so I thought he knew what he was doing so I left it!! It doesnt make any difference. I still get the same error. echo $ro; = 27042007 echo $co; = 12 echo $a_diary[$ro][$co]; Notice: Undefined index: 27042007 Have you any other thoughts please, Ive run out of ideas !! Darren Quote Link to comment Share on other sites More sharing options...
Barand Posted April 27, 2007 Share Posted April 27, 2007 What is in $startOfWeek? Quote Link to comment Share on other sites More sharing options...
DazlerD Posted April 27, 2007 Author Share Posted April 27, 2007 Hi Barand $startOfWeek contains the date of the previous sunday or today if today is a sunday. Weeks run from Sunday to Saturday. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.