durangod Posted February 20, 2014 Share Posted February 20, 2014 (edited) Hi, I am trying to connect to the db in a function im working on. For the Mysqli library you must have the db connection live to use the function so i need to do something like $db = new ?????? the ? is what i dont know, whats the WHMCS class name for a new db connection. Im looking at the api now but not seeing it. what im doing is working on the old bridge code to phpbb that i found on here, i am converting it to Mysqli library as you can see i have added the connection var as required by the new library example mysqli_query($db,$sqlcmd) but inside the function i must assign $db to a new connection and i dont know what that class is on the whmcs side. /* ########################## WHMCS SIDE ############################ */ function getusername($userid) { $db = new ???? global $user_fieldid; $sqlcmd = "select value from tblcustomfieldsvalues where fieldid=$user_fieldid and relid=$userid"; $result = mysqli_query($db,$sqlcmd) or die("mysqli Error in getting Username :".mysqli_error($db)); while ($row = mysqli_fetch_object($result)) { return $row->value; } } function getuserpass($userid) { $db = new ???? global $pass_fieldid; $sqlcmd = "select value from tblcustomfieldsvalues where fieldid=$pass_fieldid and relid=$userid"; $result = mysqli_query($db,$sqlcmd) or die("mysqli Error in getting Username :".mysqli_error($db)); while ($row = mysqli_fetch_object($result)) { return $row->value; } } add_hook("ClientAdd",1,"create_forum_account"); ?> Edited February 20, 2014 by durangod 0 Quote Link to comment Share on other sites More sharing options...
durangod Posted February 20, 2014 Author Share Posted February 20, 2014 This does not solve it because i think this doc is old, there is no way that WHMCS is still on the mysql library. http://docs.whmcs.com/SQL_Helper_Functions 0 Quote Link to comment Share on other sites More sharing options...
durangod Posted February 20, 2014 Author Share Posted February 20, 2014 i am going to try it this way instead and see if it works. function getusername($userid) { global $user_fieldid; $table = "tblcustomfieldsvalues"; $fields = "fieldid,relid,value"; $where = array("fieldid"=>$user_fieldid), array("relid"=>$userid); $result = select_query($table,$fields,$where); while ($row = mysqli_fetch_object($result)) { return $row->value; } }//close function function getuserpass($userid) { global $pass_fieldid; $table = "tblcustomfieldsvalues"; $fields = "fieldid,relid,value"; $where = array("fieldid"=>$pass_fieldid), array("relid"=>$userid); $result = select_query($table,$fields,$where); while ($row = mysqli_fetch_object($result)) { return $row->value; } }//close function 0 Quote Link to comment Share on other sites More sharing options...
durangod Posted February 22, 2014 Author Share Posted February 22, 2014 i got this figured out just had to go back to normal normal config and normal sql queries. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.