Mysql $db->query() error on echo

Lu Jia

Active member
Hi,
today I got a problem to output the result of a query:
PHP:
$group_founder = 1;
$group_founder_username = $db->query("SELECT username FROM `xf_user` WHERE user_id = '$group_founder';");
echo $group_founder_username;

When i save this file i'll have this error:
Code:
Server Error

Object of class Zend_Db_Statement_Mysqli could not be converted to string

XenForo_Application::handlePhpError() in ExternalPages/ControllerPublic/Group/Index.php at line 101
ExternalPages_ControllerPublic_Group_Index->actionIndex() in XenForo/FrontController.php at line 310
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
XenForo_FrontController->run() in /abosulutepath/index.php at line 17

I'm using ExternalPages addon :)

I removed the echo and put the variable in the template:

PHP:
$viewParams = array(
    'group_founder' => $group_founder_username,
);

I'll have this error on the top of the page:

HTML:
Template Errors: EP_Group_Index
htmlspecialchars() expects parameter 1 to be string, object given in /absolutepath/library/XenForo/Template/Abstract.php(262) : eval()'d code, line 316:
315:            <dt>Founder del gruppo:</dt>
316:            <dd>' . htmlspecialchars($group_founder) . '</dd>
317:    </dl>

Any suggestions to fix it?

Abstract.php file:

PHP:
        if ($this->_usingTemplateFiles())
        {
            include($__template);
        }
        else
        {
            eval($__template);
        }

        return $__output;
    }

line 262 : eval($__template);
 
sorry i put
PHP:
$group_founder = 1;
but really is
PHP:
$group_founder = $group_data[0]['founder'];
I guess the problem isn't here.
 
Top Bottom