1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how i can fix this error " Illegal offset type "

Discussion in 'XenForo Development Discussions' started by TBDragon, Feb 16, 2014.

  1. TBDragon

    TBDragon Active Member

    how r u guys

    i have a small issue that i need to get phrase text by title of phrase

    for example

    PHP:
                    $phrase = new XenForo_Phrase("thread_prefix_4");
                    
    $phrase $phrase->render(true);
    this one return for me the title of prefix 4 in my forum !!

    but for me i want to show many prefix

    so i try to do this code

    PHP:
                foreach ($prefixIds as $prefixId ) {
                    
    $phrase = new XenForo_Phrase('thread_prefix_ . $prefixIds[$prefixId]');
                    
    $phrase $phrase->render(true);
                    
    self::$PrefixHtml .= "<li> prefix ? = " $phrase "</li>";
                }
    but i got an error

    Code:
    Server Error
    Illegal offset type
    [LIST=1]
    [*]XenForo_Application::handlePhpError() in TBDragon/PrefixList/PrefixListCallback.php at line 32
    [*]TBDragon_PrefixList_PrefixListCallback::formatPrefix() in TBDragon/PrefixList/PrefixListCallback.php at line 50
    [*]TBDragon_PrefixList_PrefixListCallback::respond()
    [*]call_user_func_array() in XenForo/ControllerPublic/Page.php at line 46
    [*]XenForo_ControllerPublic_Page->actionIndex() in XenForo/FrontController.php at line 347
    [*]XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
    [*]XenForo_FrontController->run() in C:/wamp/www/xen/index.php at line 13
    [/LIST]
    
    

    so how i can solve this ?

    i think there was a problem with the geting value from the array

    as line 32 is this

    PHP:
                    $phrase = new XenForo_Phrase('thread_prefix_ . $prefixIds[$prefixId]');
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    There was indeed a problem getting the value from the array.

    The correct way to get that value would be:

    PHP:
    $phrase = new XenForo_Phrase('thread_prefix_' $prefixId);
     
    TBDragon likes this.
  3. TBDragon

    TBDragon Active Member

    i got this error

    Code:
    Server Error
    Array to string conversion
    
    [LIST=1]
    [*]XenForo_Application::handlePhpError() in TBDragon/PrefixList/PrefixListCallback.php at line 31
    [/LIST]
    
    where line 31 is this

    PHP:
                 
                    $phrase 
    = new XenForo_Phrase('thread_prefix_' $prefixId);



    and thanks for replay and help
     
    Last edited: Feb 16, 2014
  4. Chris D

    Chris D XenForo Developer Staff Member

    That suggests that $prefixId is an array. Maybe $prefixId['prefix_id'] would work but you should really try to dump $prefixId to confirm what content it contains.
     
    TBDragon likes this.
  5. TBDragon

    TBDragon Active Member

    thanks

    this what i forget to do :$ :$ .,


    now its work fine ^_^
     
    Chris D likes this.

Share This Page