Howdy, Stranger!

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

Categories

problem about getting info from a file

fnoyanfnoyan Member Posts: 103
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

  • mac_doggiemac_doggie Member Posts: 488
    : 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:[email protected]
    the Netherlands...


  • Justin BibJustin Bib USAMember Posts: 0

    // http://forcoder.org // free ebooks and video tutorials about // PL/SQL Perl Python Visual Basic Visual Basic .NET C# Assembly Scratch Delphi Go R PHP MATLAB C++ C Java Objective-C Ruby Swift JavaScript F# ML Clojure D LabVIEW COBOL Scheme Dart FoxPro Logo SAS Lisp Kotlin Rust Lua VBScript Prolog Alice Crystal Erlang Awk Scala Julia Hack Ada Bash Fortran Apex Transact-SQL ABAP // ___________

Sign In or Register to comment.