Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 11 May 2013, 23:38
kronnos kronnos is offline
 
Join Date: Apr 2006
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!
Reply With Quote
  #2  
Old 12 May 2013, 00:38
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #3  
Old 12 May 2013, 00:57
tbworld tbworld is offline
 
Join Date: Oct 2008
Originally Posted by kh99 View Post
IIRC
IIRC <--- "If I recall correctly"
Okay "kh99" stop making me feel old. I had to look this one up.
Reply With Quote
  #4  
Old 12 May 2013, 00:59
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by tbworld View Post
IIRC <--- "If I recall correctly"
Okay "kh99" stop making me feel old. I had to look this one up.
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.
Reply With Quote
  #5  
Old 12 May 2013, 02:47
kronnos kronnos is offline
 
Join Date: Apr 2006
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!


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #6  
Old 12 May 2013, 02:49
darnoldy darnoldy is offline
 
Join Date: Dec 2004
Originally Posted by kh99 View Post
But I think those abbreviations aren't technically allowed in this forum, so I'm not setting a very good example.
IM(NS)HO, us old guys should take pride in our abbreviations! LMAO

--don
Reply With Quote
  #7  
Old 12 May 2013, 05:20
tbworld tbworld is offline
 
Join Date: Oct 2008
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

Last edited by tbworld; 12 May 2013 at 06:12.
Reply With Quote
  #8  
Old 12 May 2013, 05:28
kronnos kronnos is offline
 
Join Date: Apr 2006
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!
Attached Files
File Type: php ds.php (169.1 KB, 4 views)
Reply With Quote
  #9  
Old 12 May 2013, 05:57
tbworld tbworld is offline
 
Join Date: Oct 2008
Originally Posted by kronnos View Post
So do you mean if I change for example

if ( $awc_goal['extra'] == 2 )


Set a var_dump on:
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It may not display any useful information without collecting the data for analysis, but take it one step at a time.

What tools do you have at your disposal for debugging? I can help you better if I know your limitations. We all have them

Last edited by tbworld; 12 May 2013 at 06:10.
Reply With Quote
  #10  
Old 12 May 2013, 06:06
kronnos kronnos is offline
 
Join Date: Apr 2006
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?
Reply With Quote
  #11  
Old 12 May 2013, 06:33
tbworld tbworld is offline
 
Join Date: Oct 2008
I believe your code warning is about line 295. So edit that file and on line 294 put.
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This will display to the screen then php will die.

This may not give us the any useful data as the error may not have occurred as of yet. In fact it probably did not, but lets see what it says first.
The buffered var_dump code you found is important ... but hold off. Maybe you will get lucky.

Then try moving die to the end of loop so that you display more data. The data may end up being positioned all over your screen. Normally we write this data to an external file or an array.

Last edited by tbworld; 12 May 2013 at 07:13.
Reply With Quote
  #12  
Old 12 May 2013, 11:29
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by kronnos View Post
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.
I think another possibility is something like $somevar[$someothervar]. I don't see that anywhere around line 296, but maybe the line number is wrong for some reason. (The string 'ds' does appear in a number of places, so it is a string that's being used in that code).

You could try putting

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

at the top of the file.

Last edited by kh99; 12 May 2013 at 12:05.
Reply With Quote
  #13  
Old 12 May 2013, 12:15
kapii kapii is offline
 
Join Date: May 2008
TBH I would just stop using that mod and switch to this one, http://www.vbulletin.org/forum/showthread.php?t=287053

It is fully supported and is pretty cool.

EDIT: Nevermind I just realized this is vB3 that mod is vB4 only, sorry.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 01:57.

Layout Options | Width: Wide Color: