• Debian 11 has reached its end-of-life (vendor EOL date - August 31, 2026). Plesk Obsidian 18.0.81 is the last release to support it.
    If you are running Plesk Obsidian on Debian 11, we recommend you upgrade those servers to Debian 12 using our dist-upgrade tool.
  • We plan to deprecate and remove the support for XML RPC protocol versions earlier than 1.6.9.1 in Plesk Obsidian 18.0.82. We strongly recommend that you update all existing integrations using earlier versions of the XML RPC protocol to comply with the version 1.6.9.1 specification.

php: subdomain error

R

Rached

Guest
Hi all, i would appreciate alot if any one can guide me through this issue.
In our VPS, i am hosting a domain.biz. I created subdomain.domain.biz and an ftp, mysql user for that account. I gave the subdomain mysqluser full privilleges on subdomaindB. In the subdomain.domain.biz i have a php file that connects to subdomaindB, with the hostname, dBname, username, and pass as global variables, now when i call a function inside the php file to connect to the dB, using these variables as parameters, i get:
"Access denied for user: 'apache@localhost' (Using password: YES)"
But if in the function, i use normal text as parameter, it works fine. Any idea ?

example (does not work):
<?php
$host="localhost";
$user="username";
$password="password";
$dbName = "subdomaindB";

function checkUser($userID)
{
$db = mysql_connect($host,$user,$password);
if (!$db) exit(mysql_error());
$w = mysql_select_db($dbName);
if (!$w) exit(mysql_error());
$sql = "";
$sql="any sql statement";
$result = mysql_query($sql,$db);
mysql_close();
$num_rows = mysql_num_rows($result);
mysql_free_result($result);
return $num_rows;
}
?>

example (this works)
<?php
$host="localhost";
$user="username";
$password="password";
$dbName = "subdomaindB";

function checkUser($userID)
{
$db = mysql_connect("localhost","username","password");
if (!$db) exit(mysql_error());
$w = mysql_select_db("subdomaindB");
if (!$w) exit(mysql_error());
$sql = "";
$sql="any sql statement";
$result = mysql_query($sql,$db);
mysql_close();
$num_rows = mysql_num_rows($result);
mysql_free_result($result);
return $num_rows;
}
?>
 
Back
Top