Wannabe
Wannabe

Reputation: 3

3 Confusing MySQL Warnings

First of all, I'm sorry if the title isn't clear enough (I find it hard to explain what I'm dealing with, and English isn't my native language).

These two scripts cause three warnings:

Warning: mysql_pconnect() has been disabled for security reasons in /home/username/public_html/xxx/libraries/adodb/drivers/adodb-mysql.inc.php on line 227

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'root'@'localhost' (using password: NO) in /home/username/public_html/xxx/include/config.php on line 140

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/username/public_html/xxx/include/config.php on line 140

The Config PHP

    if($sban != "1")
{
    $bquery = "SELECT count(*) as total from bans_ips WHERE ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."'";
    $bresult = $conn->execute($bquery);
    $bcount = $bresult->fields['total'];
    if($bcount > "0")
    {
        $brdr = $config['baseurl']."/banned.php";
        header("Location:$brdr");
        exit;
    }
}

The adodb-mysql.inc.php

function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
    {
        if (ADODB_PHPVER >= 0x4300)
            $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword,$this->clientFlags);
        else
            $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword);
        if ($this->_connectionID === false) return false;
        if ($this->autoRollback) $this->RollbackTrans();
        if ($argDatabasename) return $this->SelectDB($argDatabasename);
        return true;    
    }

What I don't understand is that there's no error whether using localhost or my other hosting (I have 2 hosting services and only one that works well).

Please, could you kindly suggest to me what to do in a very newbie way?

Thank you very much in advance.

Upvotes: 0

Views: 189

Answers (1)

tadman
tadman

Reputation: 211740

The mysql_query subsystem requires an active connection to be defined before the escaping function will work, but don't bother fixing this. Instead use the database library you're employing correctly.

It's not clear which you're using from this short example, the connection code is omitted.

The PDO execute function can bind values, and the mysqli bind_param method is similar. Both completely replace mysql_real_escape_string.

Upvotes: 1

Related Questions