Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Trouble With Php
imacul8
post Jul 12 2006, 10:27 AM
Post #1


Member [Level 3]
******

Group: Members
Posts: 95
Joined: 21-May 06
From: Adelaide, Australia
Member No.: 24,017



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.


This post has been edited by BuffaloHELP: Jul 12 2006, 07:54 PM
Go to the top of the page
 
+Quote Post
Spectre
post Jul 12 2006, 01:43 PM
Post #2


Privileged Member
*********

Group: Members
Posts: 873
Joined: 30-July 04
Member No.: 246



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.
Go to the top of the page
 
+Quote Post
peroim
post Jul 12 2006, 03:34 PM
Post #3


Newbie [Level 2]
**

Group: Members
Posts: 33
Joined: 9-July 06
From: Belgium
Member No.: 26,367



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

This post has been edited by peroim: Jul 12 2006, 03:35 PM
Go to the top of the page
 
+Quote Post
fffanatics
post Jul 12 2006, 06:20 PM
Post #4


Privileged Member
*********

Group: [HOSTED]
Posts: 936
Joined: 14-April 05
From: West Chester, PA
Member No.: 5,636



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.
Go to the top of the page
 
+Quote Post
imacul8
post Aug 7 2006, 09:21 AM
Post #5


Member [Level 3]
******

Group: Members
Posts: 95
Joined: 21-May 06
From: Adelaide, Australia
Member No.: 24,017



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..
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Neomail, Horde, Squirrelmail(4)
  2. Trouble With Emailer.php(6)
  3. Having Trouble Installin Half Life 1 On Windows Xp(8)
  4. Windows Update Trouble(7)
  5. Trouble With Rpgmaker Xp(19)
  6. New Arisen Site Problem(2)
  7. Trouble With Phpbb Email(1)
  8. Window Media Player License.(1)
  9. Trouble Logging Into Cpanel(0)
  10. Php An Js Window.open Pages Trouble.(3)
  11. Cpanel Login Trouble!(4)
  12. I Am Having Tonnes Of Trouble.... [resolved](5)
  13. Logo Trouble(4)
  14. Login Trouble [resolved](3)
  15. [php/mysql]id Trouble [resolved](3)
  1. Wordpress Login Trouble [resolved](8)
  2. School Giving You Too Much Trouble?(1)
  3. Trouble Creating Hosting Account(20)
  4. Nasal Irrigation For Sinus Trouble(4)
  5. Runescape Through A Proxy(2)
  6. Cpanel Help, Trouble Logging In.(4)
  7. Mime Type Trouble(3)
  8. Cms?(2)
  9. The Olympics-more Trouble Than It's Worth?(6)
  10. Browser Compatibility Problem With Firefox - Javascript + Css(3)
  11. I'm Having Trouble Registering [resolved](6)
  12. Having Trouble Accessing Google(1)
  13. Need Help With Javascript Drag And Drop Script(2)


 



- Lo-Fi Version Time is now: 11th October 2008 - 11:56 AM