I'm hoping that another set of eyes will see something that I'm not.
I'm having an issue with a script that I just added a little routine to, so I know the issue is in the routine, because the sript as a whole was working before adding this...
the routine separated into a stand alone script gives me the same results (runs off in space and never stops processing..)
<?php
include "all_inc/config_site.php";
include "all_inc/pghead.php";
$links='y'; // indicates that menu should be displayed
include "all_inc/pgtop.php";
$ref_id='10000011';// set to a known good member record as initial referrer
$ref_stat='';
$cur_ref=$ref_id;
while($ref_stat!='D'){
$sql_stat = "
SELECT mem_status, ref_id
FROM members
WHERE mem_id = '$cur_ref'
";
$stat_result=mysql_query($sql_stat);
$stat_row=mysql_fetch_array($stat_result);
$ref_stat=$stat_row[0]; // holds the mem_status of cur_ref
if ($ref_stat !='D'){ // not an IR, so set cur_ref to next upline referrer
$cur_ref=$stat_row[1];
} // if cur_stat is a D then it will drop out of while loop
}
print"<br>When dropping out of while loop:<br>cur_ref".$cur_ref;
include "all_inc/pgbottom.php" ;
?>
Abbreviated version of members table:
mem_id mem_status ref_id
10000005 D 10000002
10000011 F 10000005
The way it should work is that the initial ref_id is 10000011
and when the query is run it gets the mem_status of that member along with the ref_id in their record, which is their referrer
In this case 10000005 referred 10000011
So the first returned result should be ref_stat is 'F'
and since it is not 'D' then it should reassign cur_ref to with the value of 10000005
Then go to the next iteration of the while loop.
and when the query is run it gets the mem_status of that member along with the ref_id in their record, which is their referrer
In the second iteration 10000002 referred 10000005
So the first returned result would set the ref_stat to 'D'
And since it is 'D' then it doesn't need to reset the cur_ref, and it should drop out of the while loop
and simply print what the cur_ref value is
Should be super simple, but for some reason, it never stops processing, and I can't get it to display anything that would give me a clue as to what is going wrong...
Any suggestions would be greatly appreciated.
Thanks
Douglas