The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Illegal string offset Error - Any ideas?
Anyone have any idea what this error could mean on top of the page?
Warning: Illegal string offset 'ds' in [path]/awcoding/plugins/awc.php on line 296 Its showing up for only on top of threads that have a donation award image under username in their post. Here is what line 296-300 of the awc.php looks like: if ( $awc_goal['extra'] == 2 ){ print_description_row( $vbphrase['awc_goal_extra_2'], 0, 2, 'thead', $stylevar['left'] ); } else { print_yes_no_row( $vbphrase['awc_goal_extra'], 'extra_'.$awc_goal['id'], $awc_goal['extra'] ); } I doubt I would get any help from the mod developer since its in the graveyard but i would atleast want to figure out a temp fix untill I chnage to something else. BTW - I think this started to happen after I updated server to latest php version 5.4. Thanks! |
#2
|
|||
|
|||
I think that error happens when you have code like $somevar['ds'] and $somevar is a string. You can have something like $somevar[4] to get the 4th char in the string, but IIRC before 5.4 using a string would just default to 0, and now it generates a warning.
But I don't see any 'ds' being used in square brackets, so I don't see what's causing it. |
#3
|
|||
|
|||
IIRC <--- "If I recall correctly"
Okay "kh99" stop making me feel old. I had to look this one up. |
#4
|
|||
|
|||
lol, it's likely I'm as old as you are. But I think those abbreviations aren't technically allowed in this forum, so I'm not setting a very good example. Edit: but I don't see it in the rules, so it's OK, I guess I'm thinking of a different forum.
|
#5
|
|||
|
|||
Thanks. i didnt know much what to do with that so i went looking for the ['ds'] in the file elsewhere but could not find anything. I even tried changing "if ( $awc_goal['extra'] == 2 )" to "if ( $awc_goal[0] == 2 )" and doing a bunch of other weird things to see how it impacts anything but didnt really chnage. I even deleted the entire first If statement and it kept giving me the same error at the start of the second if statement.
Maybe its something at the end of the if statements having to do with "$lastid = $awc_goal['id']; and $lastsid = $awc_goal['sid'];" ? If there is no obvous answer, is there a way to just turn of erro reporting for that specific page? Second option would be to completely disable the mod but it works fine for what I need until I can migrate. Thanks! PHP Code:
|
#6
|
|||
|
|||
Quote:
--don |
#7
|
|||
|
|||
Your problem is in reference to this change in php.
Non-numeric string offsets - e.g. $a['foo'] where $a is a string - now return false on isset() and true on empty(), and produce a E_WARNING if you try to use them. Offsets of types double, bool and null produce a E_NOTICE. Numeric strings (e.g. $a['2']) still work as before. Note that offsets like '12.3' and '5 foobar' are considered non-numeric and produce a E_WARNING, but are converted to 12 and 5 respectively, for backward compatibility reasons. Note: Following code returns different result. $str='abc';var_dump(isset($str['x'])); // false for PHP 5.4 or later, but true for 5.3 or less http://us1.php.net/manual/en/migrati...compatible.php I could be more helpful if I knew where your code was derived from. I troubleshoot this type of problem by using zend/xdebug and var_dump the variables that are in play. Most likely a non-numeric number is being used as an offset. Anyway just my guess |
#8
|
|||
|
|||
So do you mean if I change for example
if ( $awc_goal['extra'] == 2 ) To a numeric like: if ( $awc_goal[2] == 2 ) There should not be an error? Or would I need to go deeper and find out where the variable 'extra' is defined and change it in there? Ill see if I could play with any of that.. Thanks! |
#9
|
|||
|
|||
Quote:
Set a var_dump on: Code:
var_dump($awc_goal['extra']); What tools do you have at your disposal for debugging? I can help you better if I know your limitations. We all have them |
#10
|
|||
|
|||
Sorry, not sure how to set a var dump..
Found this online: function grab_dump($var) { ob_start(); var_dump($var); return ob_get_clean(); } so would my function look like: { ob_start(); var_dump($awc_goal['extra']); return ob_get_clean(); } If so , do I just add that to the php and hope for the var to show up on the screen? |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|