Results 1 to 4 of 4

Thread: "Fatal error: Cannot use string offset as an array"

  1. #1
    Join Date
    Apr 2009
    Posts
    87

    "Fatal error: Cannot use string offset as an array"

    hi,
    I get the error message "Fatal error: Cannot use string offset as an array".for my script, I tried to export an t3d file. I tried it using the TV Page module AND the normal page module.but only in PHP5:
    Code:
    [21] => Array
    (
    [tag] => UML:CLASS
    [type] => open
    [level] => 7
    [attributes] => Array
    (
    [XMI.ID] => .:00000000000008EC
    [NAME] => quiz_batteries
    [VISIBILITY] => public
    [ISSPECIFICATION] => true
    [ISROOT] => false
    [ISLEAF] => false
    [ISABSTRACT] => true
    [ISACTIVE] => false
    )
    
    [value] =>
    
    )
    
    $xmlarray[$x]['tag']['attributes']['NAME']

    and I also get the same error on $id=$xmlarray[$x]['tag']['attributes']['XMI.ID'].

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: "Fatal error: Cannot use string offset as an array"

    I guess the suggested patches will not fix the problem:

    You would have to test if $editData is an array, $editData[$key] is an array and $value is an array for both calls - the recursion and the call to $this->callBackObj->$PA['callBackMethod_value'] since all of this three may become strings in somehow broken content .

    If you do so, the fatal error is no longer spit in flexformtools, but may occur in class.tx_templavoila_htmlmarkup.php line 540 (FE) and class.t3lib_tceforms.php on line 2595 (BE, editing of the record).

    I found german umlauts in my content as well, but there are tons of working flexdata with umlauts while others break.

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: "Fatal error: Cannot use string offset as an array"

    The reason you're saw those results is that PHP allows you to manipulate a string as if it were an array. BUT, despite the fact that the array elements exist, it really isn't an array, so you can't treat the elements as if they are true array elements.

    Code:
    $arr['a'] = "foo";
    The above statement assigns a string (aka, an array of characters) to an element of $arr. The array (ahem, "string") has three elements ("f", "o", "o"). You can treat $arr['a'] as an array, but you aren't allowed to change the fact that the content of $arr['a'] is a string. Thus,

    Code:
    echo $arr['a'][1]; // prints "o"
    When you tried to assign a new string to the second element you tried to treat $arr['a'] as a normal array, but it isn't. It's a string that you can manipulate as an array-like way. PHP did the best it could with what you asked, which was to take the first element of the "array" you were trying to assign and assign it to the one element you had referenced.

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: "Fatal error: Cannot use string offset as an array"

    The first thing that I see a problem with is your for loop statement.

    for ($i=0; $i servicesTimeintransit[$type])) {

    It should be in the form of

    for ($i=0; $i<$var; $i++) {

    I think you are getting “Fatal error: Cannot use string offset as an array” because servicesTimeintransit[$type] is an array and not an int or string. I gathered that servicesTimeintransit[$type] is an array as you are calling servicesTimeintransit[$type]["date"] two lines down.

    I hope that helps.

Similar Threads

  1. Replies: 5
    Last Post: 07-05-2012, 06:02 PM
  2. Replies: 5
    Last Post: 19-03-2012, 09:48 AM
  3. Replies: 4
    Last Post: 27-03-2011, 04:01 AM
  4. Replies: 5
    Last Post: 25-02-2011, 04:47 PM
  5. "FATAL: Module not found error" using modprobe
    By Alysa in forum Operating Systems
    Replies: 5
    Last Post: 24-04-2010, 12:49 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,066,376.78334 seconds with 16 queries