1
mjoel
mysql query with XOOPS 2.581
  • 2017/2/20 22:52

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


I have this query code in one of my custom page in XOOPS 2.572..and its working fine but when i upgraded to XOOPS 2.581 recently this no longer work..the page is not fully load and it stopped at this query

     global $xoopsDB
$resultmysql_query("SELECT * FROM ".$xoopsDB->prefix("myunit")." ") or die(mysql_error()); 
        while (
$row mysql_fetch_assoc($result)) {
            echo 
'$row['list_unit'] . '">' $row['list_unit'] . '';
        }
        
?>


what might be the problem ?

2
geekwright
Re: mysql query with XOOPS 2.581

As of version 2.5.8, XOOPS no longer uses the deprecated mysql extension, so the mysql connection that is required for calls like mysql_query() does not exist. This change was required to make XOOPS work with PHP 7.0 and above, where the mysql extension was removed. (See this page on supported versions of PHP to understand why that is important. Time is running out for PHP 5.) The best approach in this case is to rewrite the code to use the standard database connection calls. It would look something like this (not tested, just off the cuff.)
$result $xoopsDB->query('SELECT * FROM ' $xoopsDB->prefix('myunit'));
if (
$result===false) {
    die(
$xoopsDB->error());
}
while (
$row $xoopsDB->fetchArray($result);) {
    echo 
'$row['list_unit'] . '">' $row['list_unit'] . '';
}
Quote:
mjoel wrote: I have this query code in one of my custom page in XOOPS 2.572..and its working fine but when i upgraded to XOOPS 2.581 recently this no longer work..the page is not fully load and it stopped at this query
$resultmysql_query("SELECT * FROM ".$xoopsDB->prefix("myunit")." ") or die(mysql_error());  
        while (
$row mysql_fetch_assoc($result)) { 
            echo 
'$row['list_unit'] . '">' $row['list_unit'] . '';
        } 
        
?>
what might be the problem ?

3
mjoel
Re: mysql query with XOOPS 2.581
  • 2017/2/21 0:27

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


Thank you for the explanation Geekwright..Thats great.. happy to know XOOPS is moving forward..

Im new to this code thing..i have to check all my codes

btw...the code you gave is not working...i got a blank page

....can you help me correct the example so i can correct my code...

i have many of this and i need to correct in my other page

Thanks again

4
geekwright
Re: mysql query with XOOPS 2.581

There was a stray semicolon in while condition. This should do it.
$result $xoopsDB->query('SELECT * FROM ' $xoopsDB->prefix('myunit')); 
if (
$result===false) { 
    die(
$xoopsDB->error()); 
}
while (
$row $xoopsDB->fetchArray($result)) {
    echo 
'$row['list_unit'] . '">' $row['list_unit'] . ''
}

Login

Who's Online

300 user(s) are online (107 user(s) are browsing Support Forums)


Members: 0


Guests: 300


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