Managed to stay away for a while..lol. Lots of progress and overcome many problems, but cant work this one out..
Have not really used functions before, but now I have a need. Have written this :
and am having a problem with the two vars $t1paid and $t2paid. There is more to this function that I have deleted to debug.
When this function is called, the output is as follows:
Why are t1paid and t2paid changing back to 0 - as soon as they both hit 1, the function should have stopped? And, just noticed, how come 1005 came up twice?
My first thought was local/global vars, but the vars here are not used anywhere else, and so should be local.
Any pointers would be appreciated.
Have not really used functions before, but now I have a need. Have written this :
PHP:
<?php
function paylvlbonus($userid,$amount)
{
[COLOR=red]$t1paid=0;[/color]
[COLOR=red]$t2paid=0;[/color]
while (($t1paid==0)||($t2paid==0))
{
echo "<br />userid is ".$userid." t1paid is ".$t1paid." t2paid is ".$t2paid;
$pb= mysql_query("SELECT l1refer, teirlvl FROM members
WHERE userid = '$userid' LIMIT 1");
while($paub = mysql_fetch_array($pb))
{
$referrer=$paub['l1refer'];
$teirlvl=$paub['teirlvl'];
}
if ($userid == '1005')
{
echo "reached here";
[COLOR=red]$t1paid=1;[/color]
[COLOR=red]$t2paid=1;[/color]
echo " t1paid is ".$t1paid." t2paid is ".$t2paid;
}
$userid=$referrer;
}
}
?>
and am having a problem with the two vars $t1paid and $t2paid. There is more to this function that I have deleted to debug.
When this function is called, the output is as follows:
nb - 1005 does refer to 1004, and 1004s referrer is 1004, so that part is not the issue.screen said:userid is 1006 t1paid is 0 t2paid is 0
userid is 1005 t1paid is 0 t2paid is 0reached here t1paid is 1 t2paid is 1
userid is 1005 t1paid is 0 t2paid is 0reached here t1paid is 1 t2paid is 1
userid is 1004 t1paid is 0 t2paid is 0
userid is 1004 t1paid is 0 t2paid is 0
userid is 1004 t1paid is 0 t2paid is 0
userid is 1004 t1paid is 0 t2paid is 0
userid is 1004 t1paid is 0 t2paid is 0
userid is 1004 t1paid is 0 t2paid is 0
userid is 1004 t1paid is 0 t2paid is 0
...
...
repeated until error-too many results.
Why are t1paid and t2paid changing back to 0 - as soon as they both hit 1, the function should have stopped? And, just noticed, how come 1005 came up twice?
My first thought was local/global vars, but the vars here are not used anywhere else, and so should be local.
Any pointers would be appreciated.