1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice

php: subdomain error

Discussion in 'Plesk for Linux - 8.x and Older' started by Rached, May 30, 2005.

  1. Rached

    Rached Guest

    0
     
    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;
    }
    ?>
     
Loading...