need help in this php code


#1

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”


#2

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


#3

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


#4

You have it already, just replace split with explode.


#5

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


#6

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


#7

thanks for your replay


#8

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


#9
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


#10

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.


#11

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


#12
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


#13

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


#14
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~~

#15

i try this also not work


#16

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


#17
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