Oh I had it generating txt files that outputted the values being passed to ensure they were working. I even had ones for various parts of the functions so I know it runs fine until it gets into that loop and does the if statement checks. However I feed that loop with hard coded values of lets say 16 for both paidsub_build and useradmin_update_save but it does not work on paidsub_build and does work on useradmin_update_save
It is mind blowing. Even with the variables set to the same values how can I get different results from the same function where the only difference is that it is being run on a different hook.
The part where is breaks down is here:
PHP Code:
$sbusergroups = explode(",", $sbmemgroups2);
foreach($sbusergroups as $sbgroup)
{
$sbgroupint = intval($sbgroup);
The above code works fine in useradmin_update_save but breaks on paidsub_build even when they are for a fact processing the exact same input.
I got a b-day and graduation parties to get to today so I will deal with this more tomorrow. Thanks for all the help so far
--------------- Added [DATE]1306090100[/DATE] at [TIME]1306090100[/TIME] ---------------
Here is a good chunk of the functions (slightly edited)
PHP Code:
function first($userid, $findstuff = true, $sbaid = "", $sbmemgroups = "")
{
global $db, $vB_Groups, $sB_Groups, $sB_Names, $sB_Server, $sB_WebClan, $sB_WebDefault, $sB_WebUpper, $sB_WebProbation, $sB_WebRoot, $sbaidfield;
$fp = fopen('d_userid.txt', 'w');
fwrite($fp, $userid);
fclose($fp);
if ($findstuff)
{
$sbquery = $db->query_read("
SELECT " . TABLE_PREFIX . "userfield.field9
FROM " . TABLE_PREFIX . "userfield
WHERE " . TABLE_PREFIX . "userfield.userid = $userid
");
$sbrow = $db->fetch_array($sbquery);
$sbaid = $sbrow['field9'];
$sbquery2 = $db->query_read("
SELECT membergroupids
FROM " . TABLE_PREFIX . "user
WHERE userid = $userid
");
$sbrow2 = $db->fetch_array($sbquery2);
$sbmemgroups = $sbrow2['membergroupids'];
$fp = fopen('data.txt', 'w');
fwrite($fp, $sbmemgroups);
fclose($fp);
}
function2($userid, $sbaid, $sbmemgroups);
}
function function2($userid, $sbaid, $sbmemgroups)
{
global $db, $vB_Groups, $sB_Groups, $sB_Names, $sB_Server, $sB_WebClan, $sB_WebDefault, $sB_WebUpper, $sB_WebProbation, $sB_WebRoot, $sbaidfield;
$fp = fopen('data2.txt', 'w');
fwrite($fp, $sbmemgroups);
fclose($fp);
$sbmemgroups2 = file_get_contents('data2.txt');
$sbusergroups = explode(",", $sbmemgroups2);
$sbnever = false;
$sbalways = false;
$sbpaid = false;
//Determin what admin type the user is
foreach($sbusergroups as $sbgroup)
{
$sbgroupint = intval($sbgroup);
if ($sbgroupint == 10)
{
$sbnever = true;
}
else if ($sbgroupint == 9)
{
$sbalways = true;
}
else if ($sbgroupint == 16)
{
$fp = fopen('d_should_have_admin.txt', 'w');
fwrite($fp, $sbgroupint);
fclose($fp);
$sbpaid = true;
}
}
//Assign privlages to the selected type
if (!$sbnever)
{
if ($sbalways || $sbpaid)
{
$fp = fopen('d_has_admin.txt', 'w');
fwrite($fp, $sbpaid);
fclose($fp);
The last line shown here never gets run on paidsub_build nor does the d_should_have_admin.txt this is even if I just read contents directly drom data2.txt from when it ran via the other hook and this applies to all variables not just the $sbmemgroups2
Something goes wrong in that foreach loop and only does so in paidsub_build even when the loop is fed with the same input.
While I am new to programing in vbb I have coded for years in general html php sourcepawn java ect and never have I seen a situation where you can feed a function the same input and get different outputs where there was not complex math or randomization involved... these results are blowing my mind and the only think I can think is that the function that the paidsub_hook is running in some how forcefully prevents the running of that loop. However, that would mean that we need to get a developer or someone that really understands the vb code in and out to explain just what is going wrong here.