Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-11-2013, 09:38 PM
kronnos kronnos is offline
 
Join Date: Apr 2006
Posts: 241
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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 05-11-2013, 10:38 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 05-11-2013, 10:57 PM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
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 05-11-2013, 10:59 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
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 05-12-2013, 12:47 AM
kronnos kronnos is offline
 
Join Date: Apr 2006
Posts: 241
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:

if ( $awc_goal['extra'] == ){
    
print_description_row$vbphrase['awc_goal_extra_2'], 02'thead'$stylevar['left'] );
                                    } else {
                                        
print_yes_no_row$vbphrase['awc_goal_extra'], 'extra_'.$awc_goal['id'], $awc_goal['extra'] );
                                    }
                                    
print_yes_no_row$vbphrase['awc_goal_erenew'], 'erenew_'.$awc_goal['id'], $awc_goal['erenew'] );
                                    
print_yes_no_row$vbphrase['awc_goal_edisplay'], 'edisplay_'.$awc_goal['id'], $awc_goal['edisplay'] );
                                    
print_input_row$vbphrase['awc_goal_tag'], 'tag_'.$awc_goal['id'], $awc_goal['tag'] );
                                    
print_input_row$vbphrase['awc_goal_ord'], 'ord_'.$awc_goal['id'], $awc_goal['ord'] );
                                    
if ( 
$awc_goal['id'] != $lastid ){
        echo 
'<tbody>'
        
print_description_row"<input type=\"submit\" class=\"button\" value=\" $vbphrase[save] \" tabindex=\"1\" title=\"".$vbphrase['save_settings']."\" />"02'tfoot" style="padding:1px" align="right' ); 
        echo 
'</tbody>'
        
print_table_break();
                                    }
                                    
$lastid $awc_goal['id']; 
                                    
$lastsid $awc_goal['sid'];
                                } else {
                                    
print_stop_message'awc_no_access' );
                                }
                            } 
                            
print_submit_row$vbphrase['save'] ); 
Reply With Quote
  #6  
Old 05-12-2013, 12:49 AM
darnoldy darnoldy is offline
 
Join Date: Dec 2004
Posts: 234
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
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 05-12-2013, 03:20 AM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 05-12-2013, 03:28 AM
kronnos kronnos is offline
 
Join Date: Apr 2006
Posts: 241
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 05-12-2013, 03:57 AM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
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:
Code:
 var_dump($awc_goal['extra']);
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
Reply With Quote
  #10  
Old 05-12-2013, 04:06 AM
kronnos kronnos is offline
 
Join Date: Apr 2006
Posts: 241
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply


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

Forum Jump


All times are GMT. The time now is 12:53 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05693 seconds
  • Memory Usage 2,298KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete