how i can fix this error " Illegal offset type "

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]');
 
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);
 
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);

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:
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.
 
Top Bottom