Forums / Cotonti / Support / Problems with $cfg[]

driving me crazy

TwistedGA
#1 2009-04-08 05:09
Alright guys, having a little trouble getting a call to a configuration to work properly.

I am able to echo
$cfg['defaultcolor']
into the page, but when I try to use it in the string I need to, it doesn't insert the value it echo's like I need it to. The code is below, any help at all would be greatly appreciated. It's really odd that it will echo to the page and but wont insert into the string.
//Added Function for User_Display Creation
function Split_String($namesplit) {
    $STR_LEN = strlen($namesplit);
    $newdisplay = "";
    for ($i = 0; $i < $STR_LEN; $i++) {
        $newdisplay .= "<span style=\"color:#".$cfg['defaultcolor']."\">" . $namesplit{$i} . "</span>";
    }
    return $newdisplay;
}
$displayname = "".$ruserdisplay."";
//Added Function for User_Display Creation
[color=#CC0000]Lazymod[/color] [color=#000000]Studios[/color]
Elgan
#2 2009-04-08 05:53
   1. //Added Function for User_Display Creation
   2. function Split_String($namesplit) {
G[color=#EF2929]global $cfg;[/color]
   3.     $STR_LEN = strlen($namesplit);
   4.     $newdisplay = "";
   5.     for ($i = 0; $i < $STR_LEN; $i++) {
   6.         $newdisplay .= "<span style=\"color:#".$cfg['defaultcolor']."\">" . $namesplit{$i} . "</span>";
   7.     }
   8.     return $newdisplay;
   9. }
  10. $displayname = "".$ruserdisplay."";
  11. //Added Function for User_Display Creation

red is what i added.


EDIT: it dindt show up right. Could colours work in codes? bug not meant to?

so, you need to add a global to call cfg. so
glboal cfg; before its needed will work. make sense? php.net may explain better.
TwistedGA
#3 2009-04-08 07:23
EDIT// That fixed it. At some point, my editor saved the file do the desktop and under .inc format, never changed the highlighter or anything so I didnt even notice. Spotted it hanging out when I decided to take a break frm the stress... I made over 75 usernames trying different things to get it to work and it was all for nothing! LOL... Don't tell anyone, K? :-P
[color=#CC0000]Lazymod[/color] [color=#000000]Studios[/color]

Dit bericht is bewerkt door TwistedGA (2009-04-08 10:13, 15 jaren ago)