Jump to content

PHP arrays


DazlerD

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/48905-php-arrays/
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/48905-php-arrays/#findComment-239735
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.