Page 1 of 1

range() error

Posted: Thu May 19, 2011 9:48 pm
by fird01

Code: Select all

range(2010,2012);
ErrorException range() step exceeds the specified range
been searching and i cant find a solution for this..

Re: range() error

Posted: Thu May 19, 2011 10:06 pm
by McInfo
The range() function does not throw exceptions, so the message must come from a different part of your code.

Re: range() error

Posted: Thu May 19, 2011 11:22 pm
by fird01
McInfo wrote:The range() function does not throw exceptions, so the message must come from a different part of your code.
nope.. it is from the range function..


ErrorException [ Warning ]: range() [function.range]: step exceeds the specified range
FCPATH/application\helpers\myform_helper.php [ 27 ]

Code: Select all

22         $selected = is_null($selected) ? date('Y') : $selected;
23 
24 		/*** create the select ***/
25 		$select = '<select name="'.$id.'" id="'.$id.'">';
26 		//for( $year=$start_year;$year<=$end_year;$year++ )
27 		foreach(range($start_year,$end_year) as $year)
28 		{
29 			$select .= "<option value=\"$year\"";
30 			$select .= ($year==$selected) ? ' selected="selected"' : '';
31 			$select .= ">$year</option>\n";
32 		}
{PHP internal call} ยป MY_Exceptions::error_handler(arguments)

start_year = 2010
end_year =2012

my exception class says otherwise.. i've been searching .. but cant solve it..

Re: range() error

Posted: Fri May 20, 2011 12:22 pm
by McInfo
What version of PHP are you running?

Put var_dump($start_year, $end_year); just before the loop. What data types are those variables?

Try explicitly setting range()'s $step parameter to 1.0. I don't really expect that to do anything, but it's worth trying.

If you make a copy and strip out code, what is the shortest script that will continue to cause the error?