Jump to content

Using MySQL in template_ClientArea correctly?


No-Server

Recommended Posts

Hello,

 

when I use

function extreme_premium_ClientArea($params) {
   # ** The variables listed below are passed into all module functions **

   $serviceid = $params["serviceid"]; # Unique ID of the product/service in the WHMCS Database
   $pid = $params["pid"]; # Product/Service ID
   $producttype = $params["producttype"]; # Product Type: hostingaccount, reselleraccount, server or other
   $domain = $params["domain"];
$username = $params["username"];
$password = $params["password"];
   $clientsdetails = $params["clientsdetails"]; # Array of clients details - firstname, lastname, email, country, etc...
   $customfields = $params["customfields"]; # Array of custom field values for the product
   $conxxfigoptions = $params["configoptions"]; # Array of configurable option values for the product
$fullname = $clientsdetails["firstname"] . " " . $clientsdetails["lastname"];

   # Product module option settings from ConfigOptions array above

$steamid = $customfields["SteamID"];
$steamid = strip_tags($steamid);


$conxx = mysql_connect("xxxxxxxx","xxxxxxxx","xxxxxxxxx");
if (!$conxx)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("roleplay_rpdb", $conxx);


$resultxx = mysql_query("SELECT * FROM `players` WHERE `_SteamID` = '" . $steamid . "'");
$rowxx = mysql_fetch_array($resultxx);
<some **** defined>


mysql_close($conxx);

$code = '	
<table width="100%" cellspacing="0" cellpadding="0" class="frame">
 <tr>
   <td><table width="100%" border="0" cellpadding="10" cellspacing="0">
       <tr>
         <td width="150" class="fieldarea">Premium valid until:</td>
         <td><font color="' . $cellcol . '">' . $datevalid . '</font></td>
       </tr>
	<tr>
         <td width="150" class="fieldarea">Premium valid for:</td>
         <td>' . $hisname . ' [steamID: ' . $steamid . ']</td>
       </tr>
   </table></td>
 </tr>
</table>';
return $code;
}

 

I get

 

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\inetpub\vhosts\ideal-hosting.biz\subdomains\billing\httpdocs\includes\dbfunctions.php on line 0

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\inetpub\vhosts\ideal-hosting.biz\subdomains\billing\httpdocs\includes\dbfunctions.php on line 0

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\inetpub\vhosts\ideal-hosting.biz\subdomains\billing\httpdocs\includes\dbfunctions.php on line 0

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\inetpub\vhosts\ideal-hosting.biz\subdomains\billing\httpdocs\includes\dbfunctions.php on line 0

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\inetpub\vhosts\ideal-hosting.biz\subdomains\billing\httpdocs\includes\dbfunctions.php on line 0

 

It's only in the client area code section...

Link to comment
Share on other sites

The downloads probably are not showing because there are errors in your script (you posted them). The errors seem to indicate that your password is incorrect.

 


Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\inetpub\vhosts\ideal-hosting.biz\subdomains\billing\httpdocs\includes\dbfunctions.php on line 0

Link to comment
Share on other sites

You are connecting to another database, selecting that connection, getting the info and then closing the database connection.

That leaves no connection to the database open as when you connected to the other DB the whmcs connection was closed.

You need to reconnect again back to the whmcs db

Just after you close the db connection add this to reconnect to the whmcs db

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");

Link to comment
Share on other sites

You are connecting to another database, selecting that connection, getting the info and then closing the database connection.

That leaves no connection to the database open as when you connected to the other DB the whmcs connection was closed.

You need to reconnect again back to the whmcs db

Just after you close the db connection add this to reconnect to the whmcs db

 

Nice trick. I haven't tried to connect to another database from within WHMCS, but this makes complete sense. I'll add it to my list of tricks. Thanks :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated