I recently upgraded my whmcs version from 5.0.3 to 5.2.3.
I'm having a problem with "dbconnect.php" to execute a sql statement.
Following is the code in my Sample.php file located at whmcs_dir/Service directory.
This file was used to call whmcs APIs from my site via HttpWebRequest.
---------------------------------------------------
if( isset($_POST) )
{
if( $_POST["action"] == "addorder")
{
// codes to call whmcs addorder api goes here and order was successfully saved into whmcs database.
// after saving order, i need to execute one sql statement to meet with my project needs.
$SQL = "UPDATE tblhosting SET username='xxx', domain='xxx' WHERE orderid=123";
ExecuteQuery($SQL);
}
}
function ExecuteQuery($SQL)
{
define("CLIENTAREA", true);
require("../dbconnect.php");
require("../includes/functions.php");
require("../includes/clientareafunctions.php");
$result = mysql_query( $SQL ) or die (mysql_error());
}
---------------------------------------------------
In ExecuteQuery(...) function, after line 2 - require("../dbconnect.php"); ,
I got the error "Down for Maintenance (Err 2) An upgrade is currently in progress... Please come back soon ... ".
Complete html codes returned to my HttpWebRequest is:
<div style="border: 1px dashed #cc0000;font-family:Tahoma;background-color:#FBEEEB;width:100%;padding:10px;color:#cc0000;"><strong>Down for Maintenance (Err 2)</strong><br>An upgrade is currently in progress... Please come back soon...</div>
I also tried with whmcs SQL helper function as follow but got the same result.
$table = "tblhosting";
$update = array("username"=>"xxx","domain"=>"xxx");
$where = array("orderid"=>"123");
update_query($table,$update,$where);
---------------------------------------------------
In WHMCS faq, this error occurs because of version mismatch between server files and database.
But strange thing is that if I take out the line - require("../dbconnect.php"); from function "ExecuteQuery(...)"
and put before calling that function, it works fine. So, I don't think this is because of version.
$SQL = "UPDATE tblhosting SET username='xxx', domain='xxx' WHERE orderid=123";
require("../dbconnect.php");
ExecuteQuery($SQL);
Any idea?
functions.php and clientareafunctions.php have no problem.
Is there anything that I need to configure to make this work?
Thanks in advance!