interlog Posted June 11, 2015 Share Posted June 11, 2015 $main->set('TRIVIA_GAME_LAST_PLAYED_BY', $last_played_by['username']); $main->set('TRIVIA_GAME_LAST_PLAYED_BY_PROFILE_LINK', get_profile_link($last_played_by['id'])); $main->set("PLAY_LINK", $TS_SCRIPTS['PLAY'] . "?quiz_id=$row[id]"); $main->set("HIGH_SCORE_LINK", $TS_SCRIPTS['GAME_INFO'] . "?fn=show_high_scores&quiz_id=$row[id]"); The error in the topic title triggers at this bit of code. Any solutions to fixing it are welcome. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/296762-illegal-string-offset-username-in/ Share on other sites More sharing options...
Muddy_Funster Posted June 11, 2015 Share Posted June 11, 2015 contents of the $last_played_by[] array? (particularly the keys of said array) also, seeing your classes set method would be something of an advantage. Link to comment https://forums.phpfreaks.com/topic/296762-illegal-string-offset-username-in/#findComment-1513689 Share on other sites More sharing options...
Barand Posted June 11, 2015 Share Posted June 11, 2015 I don't know what the contents of your variables are but this is what will cause that message and show you what you should look for. A string can be treated as an array of characters, so $username = 'fred'; // you can reference the individual charcters echo $username[0]; //--> f echo $username[3]; //--> d // but if the index used is non-numeric echo $username['']; //--> illegal string offset Link to comment https://forums.phpfreaks.com/topic/296762-illegal-string-offset-username-in/#findComment-1513694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.