1
deka87
Need help with a code
  • 2010/4/27 19:06

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


hi guys,

i've got a notifications hack which doesn't work giving a blank page. here is the part of it:

//notifications hack 

...

$uids = array();
$sql "SELECT DISTINCT uid FROM ".$xoopsDB->prefix("groups_users_link")." WHERE groupid = 6";
$result $xoopsDB->query($sql);
while(
$row $xoopsDB->fetchArray($result)) {
    
$uids[] = $row['uid'];
}
...

the debug says

NoticeUndefined variablexoopsDB in file /modules/catads/admin/adsmod.php line 159

the 159 line is

$sql "SELECT DISTINCT uid FROM ".$xoopsDB->prefix("groups_users_link")." WHERE groupid = 6";
$result $xoopsDB->query($sql);

any idea how to fix this?

thanks in advance!
Mind anchors

2
zyspec
Re: Need help with a code
  • 2010/4/27 20:41

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


There's a couple of possibilities depending on where this code is being placed...

1) near the top of the file add the following line:
global $xoopsDB;

OR

2) everywhere you see
$xoopsDB
replace it with
$GLOBALS['xoopsDB']

If neither of these work, like if you're trying this in a custom page, etc. then it could be a little more involved... but I'd try one of the above methods first.

3
deka87
Re: Need help with a code
  • 2010/4/28 7:09

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


global $xoopsDB;

you made my day, zyspec! notifications on my website now respect user groups thanks!
Mind anchors