Intermittent Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Intermittent Problem

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

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

?>
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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)); 
   }
Post Reply