problem about getting info from a file

hi
the code below must get the value of $local_user_no from kayit_yapanlar.log file. Above tihs code there is a line that prints out the $user_no. I saw that the $local_user_no and the $user_no variables are the same but the code doesn't prints the error message!

NOTE: the kayit_yapanlar.log file keeps the number of users who has had a registration before.
And also I user strcmp() instead simple comparing...

$dosya_ac=fopen("./kayit_yapanlar.log","r");
while(!feof($dosya_ac))
{
$local_user_no=fgets($dosya_ac,7);
echo $local_user_no;
if("$local_user_no"=="$user_no")
{ printf("You've already had a registration!"); }
}
fclose($dosya_ac);

Thanks.....

Comments

  • : hi
    : the code below must get the value of $local_user_no from kayit_yapanlar.log file. Above tihs code there is a line that prints out the $user_no. I saw that the $local_user_no and the $user_no variables are the same but the code doesn't prints the error message!
    :
    : NOTE: the kayit_yapanlar.log file keeps the number of users who has had a registration before.
    : And also I user strcmp() instead simple comparing...
    :
    : $dosya_ac=fopen("./kayit_yapanlar.log","r");
    : while(!feof($dosya_ac))
    : {
    : $local_user_no=fgets($dosya_ac,7);
    : echo $local_user_no;
    : if("$local_user_no"=="$user_no")
    : { printf("You've already had a registration!"); }
    : }
    : fclose($dosya_ac);
    :
    : Thanks.....
    :
    Try losing the quotes around $local_user_no and placing trims(could be that there are some
    signs at the end of the line in the file.

    like:
    if(trim($local_user_no)==trim($user_no))


    If you really want to be sure you could also compare them when uppercased so your check will be case insensitive:
    if(strtoupper(trim($local_user_no))==strtoupper(trim($user_no)))

    hope this helps...


    ;-)
    -mac-
    mailto:programmersheaven@mac-doggie.nl
    the Netherlands...


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion