Thread:Project:Support desk/Fetch value from database and print it!/reply

a couple of things. $wgUser and $ wgOut are deprecated and should no longer be used (the same objects are available via resource context).

your function should look more like: (note I didnt change wgUser to new form because im typing this on my phone, and if I don't check ill probably do it wrong. however $this->getUser and $this->getOut is probably what it should be. function execute( $par ) { global $wgOut, $wgUser;

$dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'user', // $table  array( 'user_name', 'approved_account' ), // $vars (columns of the table)  array( 'user_name' => $wgUser->getName ), // $conds  __METHOD__, // name for profiling purposes  array( 'ORDER BY' => 'user_name ASC' ) // $options = array );

$wgOut->addHTML(htmlspecialchars ('Hi '.$res->user_name. ' . '.$res->approved_account. '.'));

}

hopefully I didnt make any typos ;)

the change to the where clause is for proper escaping to prevent potential sql injection. note approved_accounts is not a field in the user table. im assuming that you added it. if its not actually in the user table you would havr to do a join to whatever table it is in, instead of what is donr here. last of all the order by is kind of pointless if you are only retrieving a single result. im assuming you plan to make the query more complex later. the sql abstraction layer can be confusing at the beginning. if you have any questions please don't hesitate to ask.