1
function sql($login='root', $pass='', $db='test', $host = '')
    {           
        $this->connect = mysql_connect($host, $login, $pass) or die('MYSQL OK.');
        if($this->connect):
            mysql_select_db($db, $this->connect) or die('( <b>'.$db.'</b> ) NOT.');
            $this->check2('SET NAMES '.$this->meta);
        endif;
    }
1

1 ответ 1

1

Как-то так

function sql($login='root', $pass='', $db='test', $host = '127.0.0.1')
{           
    $dsn = 'mysql:dbname='.db.';host='.$host.';charset=utf8';
    try {
        $this->connect = new PDO($dsn, $user, $password);
    } catch (PDOException $e) {
        echo 'Подключение не удалось: ' . $e->getMessage();
    }
}

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.