Notice: Undefined variable: ctr in C:\xampp\htdocs\photo\pho
Moderator: General Moderators
Notice: Undefined variable: ctr in C:\xampp\htdocs\photo\pho
i am trying to do a number increment inside while loop
with ctr++ it works but i am getting this error
Notice: Undefined variable: ctr in C:\xampp\htdocs\photo\photoviewb.php on line 27
thanks
with ctr++ it works but i am getting this error
Notice: Undefined variable: ctr in C:\xampp\htdocs\photo\photoviewb.php on line 27
thanks
Re: Notice: Undefined variable: ctr in C:\xampp\htdocs\photo
it should be $ctr
Re: Notice: Undefined variable: ctr in C:\xampp\htdocs\photo
The variable named $ctr is undefined on line 27. That means it was not assigned a value before its value was requested on line 27. Assign it a value before the loop and the error should go away.
PHP wouldn't know it was a variable if it didn't have a $ prefix.anantha wrote:it should be $ctr
Last edited by McInfo on Thu Feb 24, 2011 5:18 pm, edited 1 time in total.
Re: Notice: Undefined variable: ctr in C:\xampp\htdocs\photo
if i assigned it a value like $ctr = "good";
then $ctr++;
i still get the same error
then $ctr++;
i still get the same error
Last edited by seuntech on Thu Feb 24, 2011 5:20 pm, edited 1 time in total.
Re: Notice: Undefined variable: ctr in C:\xampp\htdocs\photo
Post the code.
Re: Notice: Undefined variable: ctr in C:\xampp\htdocs\photo
$x = $start+$ctr+++1;
the value of $start changes
the value of $start changes
Re: Notice: Undefined variable: ctr in C:\xampp\htdocs\photo
Post all of the code related to those three variables, please.
Re: Notice: Undefined variable: ctr in C:\xampp\htdocs\photo
it is too much to post what i am doing is try to get the position of a particular picture among other picture order by id (it works) but on the lates php only it display the error and still works
Re: Notice: Undefined variable: ctr in C:\xampp\htdocs\photo
if it were you how would you get a number like 1 2 3 4 5 6 78 in a while loop
Re: Notice: Undefined variable: ctr in C:\xampp\htdocs\photo
Code: Select all
for($i=0; $i<8; $i++)Re: Notice: Undefined variable: ctr in C:\xampp\htdocs\photo
Without seeing the code, all I can say about the error is that it occurs when a script requests a value from a variable that does not yet exist.
To use a while loop to increment a number,
To use a while loop to increment a number,
Code: Select all
$i = 1; // Assigns an initial value
while ($i < 9) { // Continues until the value is 9 or greater
echo $i; // Uses the number
$i++; // Increments the number
}Re: Notice: Undefined variable: ctr in C:\xampp\htdocs\photo
thanks
but u guy are not getting the point
the code must be run inside a while loop
that is what ever u give me now will be placed inside a while loop
but u guy are not getting the point
the code must be run inside a while loop
that is what ever u give me now will be placed inside a while loop