Page 1 of 1

Intermittent Problem

Posted: Thu Dec 16, 2004 11:19 pm
by Stryks
Hi all,

I have some code in a site which I have had someone else working on while I have been getting up to speed on PHP.

The problem is that every time I have looked at it it works, but I have reports that it has failed.

The error is:

Fatal error: [] operator not supported for strings in{path}/create_account.php on line 358

{path} is a legit path obviously

The code at that line is

Code: Select all

for ($i=1; $i<32; $i++) &#123;
       // Error on the next line         	
      $dob_day&#1111;] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
   &#125;
Any idea why it would occasionally fault like this?

Thanks

Posted: Fri Dec 17, 2004 1:30 am
by John Cartwright

Code: Select all

<?php
$dob_day = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i)); 

?>

Posted: Fri Dec 17, 2004 1:36 am
by kettle_drum
Is $dob_day declared as an array before this loop?

Code: Select all

$dob_day = array();

   for ($i=1; $i<32; $i++) { 
       // Error on the next line             
      $dob_day[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i)); 
   }