Skip to content

Problem with DB connect function #5

@SimWhite

Description

@SimWhite

The problem with the DB connection inside solusvmcontrol.php here:

function db_open()
{
    require_once(realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'configuration.php'));
    $conn = mysql_connect($db_host, $db_username, $db_password);
    mysql_select_db($db_name, $conn);
    return $conn;
}

..if you set mysql_connect credentials inside the $conn variable it will be working fine. Also the same problem inside hooks.php here:

    // Check if the product id has been activated in SVMC
    require_once(realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'configuration.php'));
    $conn = mysql_connect($db_host, $db_username, $db_password);
    mysql_select_db($db_name, $conn);
    $result = mysql_query("SELECT count(*) AS count FROM tblcustomfields WHERE relid = ".$vars['pid']." AND (fieldname = 'solusvm_server' OR  fieldname = 'solusvm_api_key' OR fieldname = 'solusvm_api_hash')");
    $real_result = mysql_fetch_assoc($result);
    if($real_result['count'] != 3) {
        $smarty->_tpl_vars["SVMC"]["enabled"] = false;
    }

The DB connect function must be changed to something like:

function db_open()
{
    require_once(realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'configuration.php'));
    $conn=mysqli_connect($db_host, $db_username, $db_password);
    mysqli_select_db($conn, $db_name);
    return $conn;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions