1
Jack404
PHP/XOOPS Function Question
  • 2005/5/16 1:22

  • Jack404

  • Just popping in

  • Posts: 56

  • Since: 2003/5/16


function remUser($uid) {
  
$sql 'SELECT * FROM '.$xoopsDB->prefix('groups_users_link').' WHERE `groupid` = "'.XOOPS_GROUP_SUBSCRIBERS.'" AND uid = "'.$uid.'"';
  
$result $xoopsDB->query($sql);
  
$rows $xoopsDB->getRowsNum($result);
  if (
$rows 0) {
    
$sql 'DELETE FROM '.$xoopsDB->prefix('groups_users_link').' WHERE `groupid` = '.XOOPS_GROUP_SUBSCRIBERS.' AND `uid` = '.$uid;
    if (!
$xoopsDB->queryF($sql)) {
      return 
false;
    }
    return 
true;
  }
  return 
true;
}


This is my code for a function I'm writing. XOOPS_GROUP_SUBSCRIBERS is defined in mainfile.php, and all of that is included appropriately. This function works fine if I don't use it as a function (i.e. I put the code in where I'm calling the function), so I'm at a loss as to why it won't let me make it a function. Is it something to do with $xoopsDB? Thanks in advance for your help!

2
Dave_L
Re: PHP/XOOPS Function Question
  • 2005/5/16 1:44

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


You need to declare $xoopsDB as global within a function:

function remUser($uid) {
   [
color=ff0000]global $xoopsDB;[/color]
   
$sql 'SELECT * FROM ...

3
Jack404
Re: PHP/XOOPS Function Question
  • 2005/5/16 1:45

  • Jack404

  • Just popping in

  • Posts: 56

  • Since: 2003/5/16


AHA!

I declared it in the include page, but not in the function itself.. now it works wonderfully. Thanks so much!

Login

Who's Online

390 user(s) are online (323 user(s) are browsing Support Forums)


Members: 0


Guests: 390


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits