RE: [PHP-WIN] If statement inside of for statement
| From: | Matt Hillebrand | Date: | Mon, 10 Feb 2003 05:08:32 +0000 |
| Subject: | RE: [PHP-WIN] If statement inside of for statement | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-18423@lists.php.net to get a copy of this message | ||
Stan,
It might be because of the "\r\n" (carriage-return AND newline)
characters that Windows filesystems use. Try calling trim() on your
values before comparing them.
Matt
|-----Original Message-----
|From: Stan McCowan [mailto:stanmc@attbi.com]
|Sent: Sunday, February 09, 2003 11:06 PM
|To: Matt Hillebrand
|Subject: RE: [PHP-WIN] If statement inside of for statement
|
|
|Matt,
|I'm pasting a couple of values from a form page.
|I'm check against a flat file database.
|After the for each statement display the string $line and
|$move. the value are equal, but the if statement is not executed.
|
|Stan
|-----Original Message-----
|From: Matt Hillebrand [mailto:matt@medmarket.com]
|Sent: Sunday, February 09, 2003 7:59 PM
|To: 'Stan McCowan'
|Subject: RE: [PHP-WIN] If statement inside of for statement
|
|
|You'll have to be more descriptive than that. There's nothing
|wrong with your syntax... Although, I would add some <BR> tags
|in your output if I were you.
|
|Matt
|
||-----Original Message-----
||From: Stan McCowan [mailto:stanmc@attbi.com]
||Sent: Sunday, February 09, 2003 9:04 PM
||To: php-windows@lists.php.net
||Subject: [PHP-WIN] If statement inside of for statement
||
||
||I'm having a problem with the if statement not working inside
||of a for statement.
||
||Is there something I'm missing.
||
||<?php
||
||$auth = 'NO';
||$user=$_POST['user'];
||$pass=$_POST['pass'];
||$move=($user.":".$pass);
||
||$filename = 'ADMIN/file.txt';
||$fp = fopen( $filename, 'r' );
||$file_contents = fread( $fp, filesize( $filename ) );
||fclose( $fp );
||$lines = explode ( "\n", $file_contents );
||
|| foreach ( $lines as $line ) {
|| echo $line;
|| echo " - ";
|| echo $move;
||
|| if ($move==$line)
|| {
|| echo "This is MOVE = ";
|| $auth = 'YES';
|| break;
|| }
|| }
||?>
||
||
||
||--
||PHP Windows Mailing List (http://www.php.net/)
||To unsubscribe, visit: http://www.php.net/unsub.php
||
||
||
|
|
|
|