Jul 20, 2008

Trouble With Php

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Trouble With Php

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

QUOTE
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


CODE

// 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 smile.gif

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

 

 

 


Reply

Spectre
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.

Reply

peroim
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.)

Reply

fffanatics
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.

Reply

imacul8
thankyou for the help, havent had a chance to check it out yet, havent been able to get online for ages sad.gif

will post if i have any troubles with it still..

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics
Looking for trouble, php

Searching Video's for trouble, php
advertisement



Trouble With Php



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE