need help in this php code

i am new user in php and i want any one to help me in this code

[php]<?php

$GLOBALS[‘pay_databass1’]=“payactivedcode.dat”;

$clint_active=“1111111113”;
$clint_serial=“0000000003”;
$clint_macadd=“1234567893”;

   $lines = file( $GLOBALS['pay_databass1'] );
    if ( is_array( $lines ) )
    {
        foreach ( $lines as $line )

        {
            list( $user,$pass,$actvecode,$days,$startt_date,$endd_date,$serial,$mac) = split(",", $line );
            if((strcmp($actvecode,$clint_active) == 0)&& (strcmp($clint_serial,$serial) == 0 ))
            {
                echo "found";
            }
            else
                {
                echo "no";
                }
        }

    }

?>[/php]

the file payactivedcode.dat have this data

user1,pass1,1111111111,365,1332078114,1363614155,0000000002,1234567890,
user2,pass2,1111111112,365,1332082681,1363618681,0000000002,1234567892,
user3,pass3,1111111113,365,1332086846,1363622846,0000000003,1234567893,

naw this code when i run it it return with

notnotfound

because it try to check for $clint_active in line 3
i want it to print " found " direct with out notnot
and if i change $clint_active=“1111111113”; to be $clint_active=“1111111111”;
i got notnotnot haw to set ti to write “not”

You don’t want to use split() for that, use explode() instead. that’ll put each section into the array.

thanks for replay
can you help me haw the code will be

You have it already, just replace split with explode.

i try it and got the same telashion
look
check in the first line and not found so print no then check in the secund line and not found so print no agin then check in the therd line and found so it print found
so i can see in the proser nonofound
i want it to prit found direct on no direct

you’re the one that emailed me? i’ll see what i can do to fix it.

thanks for your replay

if there any way to finish check in wall file then go to else i think it will be better to fix this

Hello eldodo,

just add
[php]
#add belwo code after your echo ‘found’ and echo ‘no’;
break;
[/php]
other than this your code is fine.
i hope this will helpful.
Reply your feedback
SR

fixed

[php]

<?php $GLOBALS['pay_databass1']="payactivedcode.dat"; $client_active="1111111113"; $client_serial="0000000003"; $client_macadd="1234567893"; $lines = file( $GLOBALS['pay_databass1'] ); if(is_array($lines)) { foreach($lines as $line ) { list($user,$pass,$actvecode,$days,$start_date,$end_date,$serial,$mac) = explode(",", $line); if($actvecode == $client_active && $client_serial == $serial) { echo "I found a match for $user"; } else { echo "no
"; } } } ?>[/php]

You can use split, but if the host is running the latest version of php, you’ll get lots of depreciation error messages.

@ Sarthak Patel - no, you don’t want to add break, it’ll kill the entire loop. It has to move through each line to see if there’s a match and if there is, display Found or if there’s not match, tell the user that no match was found.

i try to check this and i got the same err
i got it on the brawser print as
no
no
I found a match for user3

hello eldodo, use below code. [php] <?php $GLOBALS['pay_databass1']="payactivecode.dat"; $clint_active="1111111111"; $clint_serial="0000000002"; $clint_macadd="1234567893"; $lines = file($GLOBALS['pay_databass1']); $res = '' if (is_array($lines)) { for($x=0;$x [/php]

i hope this code surely works for you.
Reply your feedback.
SR

hello my dear
many thanks for your answer
i try to check it not work not print in the broser any thing

hello eldodo, sorry there is an syntax error in code posted by me. please re try below. [php] <?php $GLOBALS['pay_databass1']="payactivecode.dat"; $clint_active="1111111111"; $clint_serial="0000000002"; $clint_macadd="1234567893"; $lines = file($GLOBALS['pay_databass1']); $res = ''; if (is_array($lines)) { for($x=0;$x [/php] this will helpful for you. reply your feedback. ~~SR~~

i try this also not work

thanks mt :Sarthak Patel
thanks for your help
many thanks for you

hello eldodo, it`s working fine for me. i have created a payactivecode.dat file which contail below data #save as payactivecode.dat user1,pass1,1111111111,365,1332078114,1363614155,0000000002,1234567890, user2,pass2,1111111112,365,1332082681,1363618681,0000000002,1234567892, user3,pass3,1111111113,365,1332086846,1363622846,0000000003,1234567893,

than create below script
[PHP]

<?php $GLOBALS['pay_databass1']="payactivecode.dat"; $clint_active="1111111111"; $clint_serial="0000000002"; $clint_macadd="1234567893"; $lines = file($GLOBALS['pay_databass1']); $res = ''; if(is_array($lines)) { for($x=0;$x

[/PHP]
Put both file in same folder.
and run php code and out put is Found
1.) if $clint_active=“1111111111”; AND $clint_serial=“0000000002”;
2.) if $clint_active=“1111111112”; AND $clint_serial=“0000000002”;
3.) if $clint_active=“1111111113”; AND $clint_serial=“0000000003”;
other than this output is Not Found.
Follow same step i hope your issue is resolve
SR

Sponsor our Newsletter | Privacy Policy | Terms of Service