1
goffy
xoopsDB and mysql_fetch_assoc
  • 2016/8/8 15:27

  • goffy

  • Just can't stay away

  • Posts: 535

  • Since: 2010/12/27


Hi

can someone help me:

Xoops 2.5.7.2
php 5.6.19

This code works:
$sql 'SELECT * FROM piwik_site;';
$result $xoopsDB->query($sql);
while (
$row mysql_fetch_assoc($result)) {
      echo 
"result row:".$row['name'];
}


why does
...
while (
$row mysqli_fetch_assoc($result)) {
...

not working?
Quote:
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, resource given in...

2
Mamba
Re: xoopsDB and mysql_fetch_assoc
  • 2016/8/8 16:39

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


First, if possible, avoid any direct MySQL command, instead, use XOOPS.

So in this case, try:

$GLOBALS['xoopsDB']->fetchArray
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

3
goffy
Re: xoopsDB and mysql_fetch_assoc
  • 2016/8/8 17:44

  • goffy

  • Just can't stay away

  • Posts: 535

  • Since: 2010/12/27


hi mamba

works, thank you

one additional basic question:
what should be used:
global $xoopsDB;
...
$result $xoopsDB->query($sql);
...

or
...
$result $GLOBALS['xoopsDB']->query($sql);
...

or is this equal?

4
Mamba
Re: xoopsDB and mysql_fetch_assoc
  • 2016/8/8 23:28

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


Both are the same, but the trend is to use more:

$GLOBALS['xoopsDB']


as it shows in the code that the object or variable you're working with, is "GLOBAL", so it will make future code refactoring easier.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

Login

Who's Online

249 user(s) are online (144 user(s) are browsing Support Forums)


Members: 0


Guests: 249


more...

Donat-O-Meter

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

Latest GitHub Commits