growe Posted July 15, 2012 Share Posted July 15, 2012 I have an add-on that uses this code... global $db_host,$db_username,$db_password,$db_name; $whmcssql = mysql_connect($db_host,$db_username,$db_password); mysql_select_db($db_name,$whmcssql) or die("Could not connect to the database"); The listed code worked up until version 5.1.2 Can someone help me figure out why it no longer works 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted July 15, 2012 Share Posted July 15, 2012 With an addon module the mysql connection is already established so you shouldn't need any of the code you listed above just jump right to using mysql_query(), etc and it will automatically use the database connection already established by WHMCS. 0 Quote Link to comment Share on other sites More sharing options...
growe Posted July 15, 2012 Author Share Posted July 15, 2012 The module itself connects to an external database so I had that code at the end to reset things back to the way it was before the module ran. Without it, after the module ran, WHMCS was trying to connect to the external database instead of the correct one. Now after the upgrade to the latest WHMCS version, the add-on does not work. 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted July 15, 2012 Share Posted July 15, 2012 Ah ok. I just tested this myself and it looks like the variables from the configuration.php file are not available from an addon module in 5.1 so a quick fix would be to include the config file: include("../configuration.php"); $whmcssql = mysql_connect($db_host,$db_username,$db_password); mysql_select_db($db_name,$whmcssql) or die("Could not connect to the database"); 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.