1 Replies - 542 Views - Last Post: 30 July 2009 - 12:29 AM Rate Topic: -----

#1 lse123  Icon User is offline

  • D.I.C Head

Reputation: -4
  • View blog
  • Posts: 68
  • Joined: 26-May 08

show problem in scope of var[for loop since, of the two assignments

Post icon  Posted 30 July 2009 - 12:11 AM

further tests I make show problem in scope of var[for loop since, of the two assignments neither pass: $f="y";]...how do it not only in for loop valid ?
since below the $f="y"; does NOT pass by anyway but rather pass initial $f="n"; for any value in text field ?
How a var in for loop[and this in a function] done global var ?

<?php
...
$f="n";
function check_username($username){
 for ($j=0;$j<$count;$j++) {
	$rowajax = @mysql_fetch_assoc($resultajax);

	if (strtolower($rowajax['email']) == strtolower($username)) {  
					  $f = "y";
					  break;
	}
	 $f="y";
}
}
echo check_username($username);   // after this the $f=is always="n"; the $f="y"; do not get done
...
?>



Is there any other way interupt a loop except"
break; ???

Is This A Good Question/Topic? 0
  • +

Replies To: show problem in scope of var[for loop since, of the two assignments

#2 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: show problem in scope of var[for loop since, of the two assignments

Posted 30 July 2009 - 12:29 AM

try this:
<?php
$f="n";
function check_username($username){
while($rowajax = mysql_fetch_assoc($resultajax)){
if (strtolower($rowajax['email']) == strtolower($username)) {  
                      $f = "y";
                      break;
    }
     $f="y";

}
echo check_username($username);   // after this the $f=is always="n"; the $f="y"; do not get done

}//function closed
?>


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1