本文整理汇总了PHP中mysql_connect_error函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_connect_error函数的具体用法?PHP mysql_connect_error怎么用?PHP mysql_connect_error使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_connect_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: open_connection
public function open_connection()
{
$this->connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
if (mysqli_connect_errno()) {
die("Database connectio failed!" . mysql_connect_error() . " (" . mysqli_connect_errno() . ")");
}
}
示例2: __construct
private function __construct()
{
$this->_connection = new mysqli($this->_host, $this->_username, $this->_password, $this->_database);
if (mysqli_connect_error()) {
trigger_error("Failed to conencto to MySQL: " . mysql_connect_error(), E_USER_ERROR);
}
}
示例3: __construct
private function __construct()
{
$this->conn = new \mysqli($this->servername, $this->username, $this->password, $this->dbname);
if (mysqli_connect_error()) {
trigger_error("Failed to connect to MySQL: " . mysql_connect_error(), E_USER_ERROR);
}
}
示例4: getConnectionLocal
public function getConnectionLocal()
{
try {
$ini = parse_ini_file("config.ini", TRUE);
$this->setLoginBanco(base64_decode($ini['local']['usuario']));
$this->setSenhaBanco(base64_decode($ini['local']['senha']));
$this->setServidorBanco(base64_decode($ini['local']['server']));
$this->setPortaBanco(base64_decode($ini['local']['porta']));
$this->setDatabase(base64_decode($ini['local']['database']));
// if(!isset(self::$instance)){
// self::$instance = new PDO('mysql:host=$this->servidor;dbname=$this->database', $this->loginBanco, $this->senhaBanco, array(PDO::MYSQL_ATTR_INIT_COMMAND=>"SET NAMES utf8"));
// self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// self::$instance->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING);
// }
$conecta = mysql_connect($this->servidor, $this->loginBanco, $this->senhaBanco) or die("Erro ao conectar o banco de dados. Especificação técnica: " . mysql_connect_error());
mysql_select_db($this->database, $conecta);
mysql_set_charset('utf8', $conecta);
// $mysql = new mysqli($this->servidor, $this->loginBanco, $this->senhaBanco, $this->database, $this->porta);
// echo "Servidor: ".$this->servidor."\n";
// echo "Usuário: ".$this->loginBanco."\n";
// echo "Senha: ".$this->senhaBanco."\n";
// echo "Database: ".$this->database."\n";
return $conecta;
// return self::$conecta;
// return self::$instance;
} catch (Exception $ex) {
echo "Ocorreu um erro na conexão. Erro: " . $ex->getMessage();
}
}
示例5: __construct
/**
* Construtor
*/
private function __construct()
{
$this->connection = new mysqli($this->host, $this->usuario, $this->psw, $this->database);
if (mysqli_connect_error()) {
trigger_error("Falha ao conectar, erro: " . mysql_connect_error(), E_USER_ERROR);
}
}
示例6: __construct
private function __construct()
{
$this->_connection = new mysqli($this->DB_host, $this->DB_user_name, $this->DB_user_password);
// Error handling
if (mysqli_connect_error()) {
trigger_error("Failed to conencto to MySQL: " . mysql_connect_error(), E_USER_ERROR);
}
}
示例7: __construct
private function __construct()
{
$this->_conexao = new mysqli($this->_servidor, $this->_usuario, $this->_senha, $this->_database);
// Erro
if (mysqli_connect_error()) {
trigger_error("Erro ao conectar MySQL: " . mysql_connect_error(), E_USER_ERROR);
}
}
示例8: __construct
private function __construct()
{
$this->_config = parse_ini_file(CONFIG_PATH);
$this->_connection = new mysqli($this->_config['host'], $this->_config['user'], $this->_config['pass'], $this->_config['db']);
if (mysqli_connect_error()) {
die("Failed to conencto to MySQL: " . mysql_connect_error());
}
}
示例9: __construct
/**
* Constructor de la capa de abstraccion
*/
private function __construct()
{
$this->connection = new mysqli($this->servidor, $this->usuario, $this->password, $this->base_datos);
$this->connection->set_charset("utf8");
if (mysqli_connect_error()) {
trigger_error("Failed to conect to MySQL: " . mysql_connect_error(), E_USER_ERROR);
}
}
示例10: __construct
private function __construct()
{
$this->_connection = new mysqli($this->_host, $this->_username, $this->_password, $this->_database);
// Error handling
if (mysqli_connect_error()) {
trigger_error("Failed to conencto to MySQL: " . mysql_connect_error(), E_USER_ERROR);
}
$this->_connection->set_charset("utf8");
}
示例11: __construct
private function __construct()
{
require_once 'db_config.php';
$this->_connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
// Error handling
if (mysqli_connect_error()) {
trigger_error("Failed to connect to MySQL: " . mysql_connect_error(), E_USER_ERROR);
}
$this->_connection->set_charset("utf8");
}
示例12: __construct
function __construct($username, $password, $server, $databank)
{
$this->username = $username;
$this->password = $password;
$this->databank = $databank;
$this->server = $server;
$this->connection = mysqli_connect($server, $username, $password, $databank);
if (!$this->connection) {
exit("Connection failed: " . mysql_connect_error());
}
}
示例13: __construct
private function __construct()
{
mysqli_report(MYSQLI_REPORT_STRICT);
try {
$this->_connection = new mysqli($this->_host, $this->_username, $this->_password, $this->_database);
} catch (mysqli_sql_exception $e) {
throw new Exception($e->getMessage());
}
if (mysqli_connect_error()) {
trigger_error("Failed to conencto to MySQL: " . mysql_connect_error(), E_USER_ERROR);
}
}
示例14: conectarse
function conectarse()
{
$enlace = mysqli_connect($this->host, $this->usuario, $this->contrasena, $this->baseDatos);
if ($enlace) {
//echo "Conexion exitosa"; //si la conexion fue exitosa nos muestra este mensaje como prueba, despues lo puedes poner comentarios de nuevo: //
} else {
die('Error de Conexión (' . mysql_connect_errno() . ') ' . mysql_connect_error());
}
return $enlace;
mysqli_close($enlace);
//cierra la conexion a nuestra base de datos, un ounto de seguridad importante.
}
示例15: __construct
function __construct()
{
require 'datos_conexion.inc';
$this->_host = $servidor;
$this->_username = $usuario;
$this->_password = $contrasena;
$this->_database = $nombreBase;
$this->_connection = new mysqli($this->_host, $this->_username, $this->_password, $this->_database);
// Error handling
if (mysqli_connect_error()) {
trigger_error("Failed to conencto to MySQL: " . mysql_connect_error(), E_USER_ERROR);
}
}