Re: [PHP] Array Elements & While Loops

2001-10-01 Thread Steve Cayford

Where is the closing brace for your while loop?

-Steve

On Monday, October 1, 2001, at 07:04  AM, Tom Churm wrote:

> hi,
>
> my problem is this:  i'm using a while loop to check elements in an
> Array for valid email syntax.  if $User[0] is a valid email address but
> $User[1] is not, the code for $User[0] is still executed before the die
> statement.  i need my loop to finish checking ALL array elements for
> validity, and to then die BEFORE any further code is executed.  here's
> what i have now (it doesn't work):
>
> //loop to check for bad email addresses:
> $j = 0;
> $flag = 0;
> while ($j < count($User)){
> if
> (($User[$j]!="")&&!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-
> z0-9-]+(\.[a-z0-9-]+)*$",
> $User[$j]))
> {
>   $flag = 1;
>   $errorNo = $j + 1;
> }
> //die if flag is 1
> if ($flag = 1) {
> die ("Email #$errorNo is not a valid e-mail
> address! href='javascript:window.history.back();'>Please return and correct
> this.");
>   }
> else {
> continue...
> }
>
> any suggestions would be great!
>
> thanks much,
>
> tom
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Array Elements & While Loops

2001-10-01 Thread Tom Churm

hi,

my problem is this:  i'm using a while loop to check elements in an
Array for valid email syntax.  if $User[0] is a valid email address but
$User[1] is not, the code for $User[0] is still executed before the die
statement.  i need my loop to finish checking ALL array elements for
validity, and to then die BEFORE any further code is executed.  here's
what i have now (it doesn't work):

//loop to check for bad email addresses:
$j = 0;
$flag = 0;
while ($j < count($User)){
if
(($User[$j]!="")&&!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$",
$User[$j])) 
{ 
$flag = 1;
$errorNo = $j + 1;
}
//die if flag is 1
if ($flag = 1) {
die ("Email #$errorNo is not a valid e-mail
address!Please return and correct
this."); 
} 
else {
continue...
}

any suggestions would be great!

thanks much,

tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]