Jump to content
xisto Community
Sign in to follow this  
imacul8

Trouble With Php

Recommended Posts

I am having a little trouble on my home page with my php script,. i get a double error

Warning: str_repeat(): Second argument has to be greater than or equal to 0. in /home/imacul8/public_html/forums/modules/navigation.php on line 115
Warning: str_repeat(): Second argument has to be greater than or equal to 0. in /home/imacul8/public_html/forums/modules/navigation.php on line 115


// Additional pages$customnavigationbits = '';$mod_options['portal_navigation_addpages'] = unserialize($mod_options['portal_navigation_addpages']);if (!empty($mod_options['portal_navigation_addpages'])){	foreach ($mod_options['portal_navigation_addpages'] AS $key => $navlinks)	{		$link = $navlinks['link'];		$title = $navlinks['text'];line 115 --- >$navmark = iif($navlinks['level'] == 1, $mod_options['portal_navigation_mark1'], str_repeat(' ', ($navlinks['level'] - 1)) . $mod_options['portal_navigation_mark2']);		eval('$customnavigationbits .= "' . fetch_template('adv_portal_navigationbits') . '";');	}}eval('$home["$mods[modid]"][\'content\'] = "' . fetch_template('adv_portal_navigation') . '";');?>

please help <_<

Notice from BuffaloHELP:
Always use QUOTE and CODE bbcodes when pasting error messages and codes.

Edited by BuffaloHELP (see edit history)

Share this post


Link to post
Share on other sites

Well, evidently, the str_repeat function requires the second argument to be of integer value above 0. The 'iif' statement isn't natively supported in PHP (nor in many other languages) as far as I know, so I'm assuming it's user-defined within one of your scripts; but a quick bit of research indicates that it operates on the basis of 'iif(condition,true,false)' meaning that it is evaluating '$navlinks['level'] - 1' if '$navlinks['level']' is any different to 1 - such as if it is 0, meaning that '$navlinks['level'] - 1' obviously become less than 0 and therefore illegal in that context. Additionally, I would recommend simply using 'condition ? true : false' as it is natively supported by both PHP and a wider range of languages, and much more likely to be recognised and understood by more people.

Share this post


Link to post
Share on other sites

This is what i found about str_repeat():

 

string str_repeat ( string input, int multiplier )

 

Gives multiplier repeats of input_str. multiplier has to be greater or equal to 0. If multiplier is 0, this fuction will return an empty string.

 

(Sorry for the possibly bad English, but I had to translate this from Dutch.)

Edited by peroim (see edit history)

Share this post


Link to post
Share on other sites

Basically, you are getting this error because $navlinks['level'] = 0 since subtracting 1 creates a negative number. Try displaying $navlinks['level'] prior to your condition so that you know its value because this will help in debugging the error. If that isnt it, then i dont know what the problem could be.

Share this post


Link to post
Share on other sites

thankyou for the help, havent had a chance to check it out yet, havent been able to get online for ages :)will post if i have any troubles with it still..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.