Error

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
I am trying to use a custom avatarimage script that I used on r63 for habworld but trying to run it on my localhost give me this error


  • Warning: str_repeat(): Second argument has to be greater than or equal to 0 in C:\inetpub\wwwroot\resource_update.php on line 121
  • This is the line of code its referring to
    PHP:
    $str = sprintf("\r[%-100s] %3d%% (%2d/%2d%s)", str_repeat("=", $length).($length==100?"":">"), $length, ($current/($unit=="kb"?1024:1)), $size/($unit=="kb"?1024:1), " ".$unit);
  • can anyone help?
 

BIOS

ಠ‿ಠ
Apr 25, 2012
906
247
What output are you trying to get from the script? Are you sure you are declaring the variables used in the code?

$length = 50;
$unit = 5;
$current = 2;
$size = 10;

$str = sprintf(
"\r[%-100s] %3d%% (%2d/%2d%s)",
str_repeat("=", $length).($length==100?"":">"),
$length,
($current/($unit=="kb"?1024:1)),
$size/($unit=="kb"?1024:1),
" ".$unit
);
echo $str;

Result:
[==================================================> ] 50% ( 2/10 5)
 

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
It used to work fine before when I used it, its for avatar imaging to host your own with your swfs, it worked fine before so Im not too sure what the issue is now, I mean it was used on r63 for habworld and im trying to use it for r63b but the figuremap and figuredata files havent changed so I dont get why it would be an issue really
 

BIOS

ಠ‿ಠ
Apr 25, 2012
906
247
It used to work fine before when I used it, its for avatar imaging to host your own with your swfs, it worked fine before so Im not too sure what the issue is now, I mean it was used on r63 for habworld and im trying to use it for r63b but the figuremap and figuredata files havent changed so I dont get why it would be an issue really
function consoleLogProgressBar($current, $size, $unit = "kb")
{
$length = (int)(($current/$size)*100);
$str = sprintf("\r[%-100s] %3d%% (%2d/%2d%s)", str_repeat("=", $length).($length==100?"":">"), $length, ($current/($unit=="kb"?1024:1)), $size/($unit=="kb"?1024:1), " ".$unit);
return $str;
}
echo consoleLogProgressBar(4, 10, 3);
This seems to work fine, maybe there's a call to the function somewhere in the code that's missing some of the arguments thus $length isn't available to them?
 

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
could my php version have anything to do with it? because it did used to work perfectlyfine when I last used it like a year ago
 

BIOS

ಠ‿ಠ
Apr 25, 2012
906
247
could my php version have anything to do with it? because it did used to work perfectlyfine when I last used it like a year ago
I doubt it being related to the PHP version, seems to be something related to the arguments used in the function

Try change the function to this temporarily and refresh the page for results:
PHP:
                function consoleLogProgressBar($current=null, $size=null, $unit = "kb"){

                    if(
                        $current && $size
                    ){

                        $length = (int)(($current/$size)*100);
                        $str = sprintf("\r[%-100s] %3d%% (%2d/%2d%s)", str_repeat("=", $length).($length==100?"":">"), $length, ($current/($unit=="kb"?1024:1)), $size/($unit=="kb"?1024:1), " ".$unit);
                        return $str;

                    }else{
                        die('call is missing required args');
                    }

                }
 

Users who are viewing this thread

Top