dual_alliance Posted July 1, 2007 Share Posted July 1, 2007 Hey, I've been trying to figure this out for a while, the function returns a result but its not the result l want. I've tried to debug the function and it seems that $groupid and $status aren't being set as when l echo'ed them out they both had no data in them. If l set the variables data inside the function the code executes perfectly, so l cant understand why it isnt working. What l need the code to do is check to see if the member logging in is an admin (group id or a root admin (group id 9) and if the game is offline (status 1) to only only admin and root admin. However is the game is offline but status is set to 2, then only root admin can login. If the game is offline, normal members are not allowed to login. Clearance is there so l can check to see whether or not to allow them pass or stop them from logging in. My code is as follows: function offlineCheck($groupid,$status) { if($status > 0){ if($groupid > 7){ return $clearance = 0; }else{ return $clearance = 1; } }elseif($status > 1){ if($groupid > { return $clearance = 0; }else{ return $clearance = 1; } }else{ return $clearance = 0; } } And what l have currently checking it is: if(offlineCheck(4,2) > 0){ echo "it worked!"; die(); } Your help is greatly appreciated, dual_alliance Quote Link to comment Share on other sites More sharing options...
trq Posted July 1, 2007 Share Posted July 1, 2007 Instead of... return $clearance = 0; You only need use.... return 0; Quote Link to comment Share on other sites More sharing options...
dual_alliance Posted July 1, 2007 Author Share Posted July 1, 2007 Thanks l didn't know about that, should save me some time in the future . However that isnt the problem, its the fact that $groupid and $status don't have any data inside of them so the result is always 0 Quote Link to comment Share on other sites More sharing options...
trq Posted July 1, 2007 Share Posted July 1, 2007 If this... offlineCheck(4,2) is how your calling the function then they do have the values 4 and 2. Add this to debugg. function offlineCheck($groupid,$status) { // add this line. die($groupid.$status); Quote Link to comment Share on other sites More sharing options...
dual_alliance Posted July 1, 2007 Author Share Posted July 1, 2007 I did as you said and this is where it gets really weird. Because the result returns nothing at all. Just to make sure, l did: echo "test1"; // add this line. die($groupid.$status); echo "test2"; Result: test1 Another test to make sure echo "test1"; // add this line. die("test3"."test4"); echo "test2"; Result: test1test3test4 So the die is defiantly working, l just cant understand why $groupid and $status have no data in them! Quote Link to comment Share on other sites More sharing options...
trq Posted July 1, 2007 Share Posted July 1, 2007 Is this all part of a class or something? Can we see your actual code? Quote Link to comment Share on other sites More sharing options...
dual_alliance Posted July 1, 2007 Author Share Posted July 1, 2007 Sorry to have wasted your time, but it seems that now the code is working again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.