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() . ")"); } }
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); } }
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); } }
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(); } }
/** * 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); } }
private function __construct() { $this->_connection = new mysqli($this->_host, $this->_username, $this->_password, $this->_database); // trata o erro, caso houver if (mysqli_connect_error()) { trigger_error("Falha ao conectar no servidor MySQL: " . mysql_connect_error(), E_USER_ERROR); } }
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); } }
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); } }
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()); } }
/** * 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); } }
private function __construct() { //$this refers to class Database and her functions and propertys are being acsessed via -> sign $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); } }
private function __construct() { $this->_connection = new mysqli($this->_host, $this->_username, $this->_password, $this->_database); // $this->_connection = new PDO("mysql:host=localhost;dbname=shopn_database", 'iphoneappuser', 'Fr040791$'); // Error handling if (mysqli_connect_error()) { trigger_error("Failed to conencto to MySQL: " . mysql_connect_error(), E_USER_ERROR); } }
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"); }
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"); }
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()); } }
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); } }
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. }
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); } }
function connection_DB($dbname) { $servername = "basidati"; $username = "******"; $password = "******"; // Create connection $conn = mysql_connect($servername, $username, $password); // Check connection if (!$conn) { die("Connection failed: " . mysql_connect_error()); } else { echo "<p>Connected successfully</p>"; } mysql_select_db($dbname); return $conn; }
public static function ActiveAdd($openid, $avtive) { $conn = mysqli_connect("localhost", "hejiyuan1", "HJYhjy@123321", "WECHAT1"); $conn->query("set names utf8"); // 检测连接 if (!$conn) { die("Connection failed: " . mysql_connect_error()); } $sql = "insert into active(openid,active) values('" . $openid . "','" . $avtive . "')"; $result = false; if (mysqli_query($conn, $sql)) { $result = true; } mysqli_close($conn); return $result; }
function sisBibAbreConexion() { global $Usuario; global $Password; global $Servidor; global $BaseDeDatos; global $DebuggingMode; global $programa; $conexionBD = mysql_connect($Servidor, $Usuario, $Password) or die("<p>======================================================================================</p>" . "<p>ABORTA Modulo: sisBibAbreConexion -- Error al conectarse al servidor de Base de Datos</p>" . "<p> La funcion fue utilizada en el modulo (" . $programa . ")</p>" . "<p> Codigo de error " . mysql_connect_errno() . ": " . mysql_connect_error() . "</p>" . "<p> Datos de conexion al servidor " . " </p><p>Servidor:(" . $Servidor . ")</p><p> Usuario:(" . $Usuario . ")</p><p> Password:(" . $Password . ")</p><p> Base de Datos:(" . $BaseDeDatos . ")</p>" . "<p>======================================================================================</p>"); if ($DebuggingMode) { echo "<p>======================================================================================</p>" . "<br>Modulo: sisBibAbreConexion envia el siguiente mensaje -- Se conecto al servidor con exito</br>" . "<br> La funcion fue utilizada en el modulo (" . $programa . ")</br>" . "<p> Datos de conexion al servidor " . " </p><p>Servidor:(" . $Servidor . ")</p><p> Usuario:(" . $Usuario . ")</p><p> Password:(" . $Password . ")</p><p> Base de Datos:(" . $BaseDeDatos . ")</p>" . "<p>======================================================================================</p>"; } $descriptor = mysql_select_db($BaseDeDatos, $conexionBD) or die("<p>======================================================================================</p>" . "<p>ABORTA Modulo: sisBibAbreConexion -- Error al seleccionar la Base de Datos</p>" . "<p> La funcion fue utilizada en el modulo (" . $programa . ")</p>" . "<p> Codigo de error " . mysql_connect_errno() . ": " . mysql_connect_error() . "</p>" . "<p> Datos de conexion al servidor " . " </p><p>Servidor:(" . $Servidor . ")</p><p> Usuario:(" . $Usuario . ")</p><p> Password:(" . $Password . ")</p><p> Base de Datos:(" . $BaseDeDatos . ")</p>" . "<p>======================================================================================</p>"); if ($DebuggingMode) { echo "<p>======================================================================================</p>" . "<br>Modulo: sisBibAbreConexion envia el siguiente mensaje -- Selecciono la Base De Datos con exito</br>" . "<br> La funcion fue utilizada en el modulo (" . $programa . ")</br>" . "<p> Datos de conexion al servidor " . " </p><p>Servidor:(" . $Servidor . ")</p><p> Usuario:(" . $Usuario . ")</p><p> Password:(" . $Password . ")</p><p> Base de Datos:(" . $BaseDeDatos . ")</p>" . "<p>======================================================================================</p>"; } return $conexionBD; //Termina sisBibAbreConexion }
private function __construct() { $this->_connection = new mysqli($this->_host, $this->_username, $this->_password, $this->_database); // Error handling if (mysqli_connect_error()) { $this->error = 1; } if ($this->error == 1) { $host = "localhost"; $username = "******"; $password = ""; $database = "maminasata"; $this->_connection = new mysqli($host, $username, $password, $database); // Error handling if (mysqli_connect_error()) { trigger_error("Failed to conencto to MySQL: " . mysql_connect_error(), E_USER_ERROR); } } }
private function __construct() { $xml = simplexml_load_file("settings/Database.xml") or die("Error: Cannot create object"); if ($xml === false) { echo "Failed loading XML: "; foreach (libxml_get_errors() as $error) { echo "<br>", $error->message; } } else { $this->_host = $xml->hostname; $this->_username = $xml->username; $this->_password = $xml->password; $this->_database = $xml->database; $this->_connection = mysqli_connect($this->_host, $this->_username, $this->_password, $this->_database); // Error handling if (mysqli_connect_errno()) { trigger_error("Failed to connect to MySQL: " . mysql_connect_error(), E_USER_ERROR); } // Change character set to utf8 mysqli_set_charset($this->_connection, "utf8"); } }
<?php if (!$_GET["id"] || ($id = (int) $_GET["id"]) <= 0) { header('Location: ' . "index.php", true, 303); die; } // connect $server = "localhost"; $username = "******"; $password = "******"; $dbname = "blog"; $conn = new mysqli($server, $username, $password, $dbname); if (!$conn) { die("Connect database failed: " . mysql_connect_error()); } // query $sql = "SELECT * FROM articles WHERE articles.id = {$id}"; $result = $conn->query($sql); // generate $row = $result->fetch_assoc(); $data = array(); $data['title'] = $row['title']; $data['author'] = $row['author']; $data['date'] = substr($row['posttime'], 0, 10); $filepath = $row['path']; $f = fopen($filepath, "r") or die("Unable to open file!"); $data['content'] = fread($f, filesize($filepath)); fclose($f); // close $conn->close(); ?>
<?php #include ("session.php"); if (isset($_POST['submit'])) { $conn = mysql_connect("localhost", "root", "ramyaj"); if (!$conn) { die('Could not connect: ' . mysql_connect_error()); } if (empty($_POST['employee_id']) || empty($_POST['last_name']) || empty($_POST['first_name']) || empty($_POST['middle_name']) || empty($_POST['month'])) { echo "<meta http-equiv='refresh' content='1;URL=dtr_august.php'/> <h1>Please fill up necessary information!</h1>\n"; } else { $employee_id = $_POST['employee_id']; $last_name = $_POST['last_name']; $first_name = $_POST['first_name']; $middle_name = $_POST['middle_name']; $regular_days = $_POST['regular_days']; $saturdays = $_POST['saturdays']; $month = $_POST['month']; $amahr1 = $_POST['amahr1']; $amamin1 = $_POST['amamin1']; $amdhr1 = $_POST['amdhr1']; $amdmin1 = $_POST['amdmin1']; $pmahr1 = $_POST['pmahr1']; $pmamin1 = $_POST['pmamin1']; $pmdhr1 = $_POST['pmdhr1']; $pmdmin1 = $_POST['pmdmin1']; $hours1 = $_POST['hours1']; $min1 = $_POST['min1']; $tmin1 = $_POST['tmin1']; $amahr2 = $_POST['amahr2']; $amamin2 = $_POST['amamin2'];
<?php if (isset($_POST["email"])) { require_once '../config.php'; require_once 'login.js'; if ($_GET['key']) { echo "not done yet"; // TODO This is where the password should actually be reset } else { $email = $_POST['email']; $g_link = mysql_connect('localhost', $g_username, $g_password); //TODO use a persistant database connections mysql_select_db('stt', $g_link); if (!$g_link) { die("Connection failed: " . mysql_connect_error()); } // TODO query the database to select their username and set $user to it // TODO generate a unique key and store it with a timestamp in the database, store the key in $key $to = $email; $subject = 'Reset your STT password'; $message = 'Use this link to reset your password:<BR><a href="10.1.50.69/login/resetPassword.php?user='******'&key=' . $key; $headers = 'From: wschwarz@ccsd.k12.ia.us' . "\r\n" . 'Reply-To: wschwarz@ccsd.k12.ia.us' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); // TODO configure sendmail on the server so this actually works $result = mail($to, $subject, $message, $headers); if ($reuslt) { echo "An email has been sent with further instructions."; } else { echo "I think the email was sent but I'm not sure, check your spam folder. The googles don't like my mail."; } } } else {
<?php $connect = new mysqli("127.0.0.1", "root", "", "medcenter"); if (mysqli_connect_error()) { trigger_error("Failed to conencto to MySQL: " . mysql_connect_error(), E_USER_ERROR); } $id = $_POST["id"]; $nome = addslashes($_POST["nome"]); $email = addslashes($_POST["email"]); $datanasc = $_POST["nasc"]; $cpf = addslashes($_POST["cpf"]); $rg = $_POST["rg"]; $endereco = addslashes($_POST["endereco"]); $bairro = addslashes($_POST["bairro"]); $cidade = addslashes($_POST["cidade"]); $estado = addslashes($_POST["estado"]); $pais = addslashes($_POST["pais"]); $sql = "UPDATE "; $sql .= "medcenter_user "; $sql .= "SET "; $sql .= "nome = '{$nome}', "; $sql .= "email = '{$email}', "; $sql .= "datanasc = '{$datanasc}', "; $sql .= "cpf = '{$cpf}', "; $sql .= "rg = '{$rg}', "; $sql .= "endereco = '{$endereco}', "; $sql .= "bairro = '{$bairro}', "; $sql .= "cidade = '{$cidade}', "; $sql .= "estado = '{$estado}', "; $sql .= "pais = '{$pais}' "; $sql .= "WHERE ";
} //close file fclose($zp); } //Now it is the time to create the mysql data //Just get the data from $CountrySQL and read data from this file //At the mean time, we should check the user need demo database or not if ($DBConnectType == 'mysqli') { $Db = mysqli_connect($HostName, $UserName, $Password); if (!$Db) { prnMsg(_('Failed to connect the database, the error is ') . mysqli_connect_error(), 'error'); } } elseif ($DBConnectType == 'mysql') { $Db = mysql_connect($HostName, $UserName, $Password); if (!$Db) { prnMsg(_('Failed to connect the database, the error is ') . mysql_connect_error(), 'error'); } } $NewSQLFile = $Path_To_Root . '/sql/mysql/country_sql/' . $CountrySQL; $DemoSQLFile = $Path_To_Root . '/sql/mysql/country_sql/demo.sql'; if (!empty($DualCompany) and $DualCompany == 1) { //we should install the production data and demo data $sql = 'CREATE DATABASE IF NOT EXISTS `' . $DatabaseName . '`'; $result = $DBConnectType == 'mysqli' ? mysqli_query($Db, $sql) : mysql_query($sql, $Db); if (!$result) { if ($DBConnectType == 'mysqli') { prnMsg(_('Failed to create database ' . $DatabaseName . ' and the error is ' . ' ' . mysqli_error($Db)), 'error'); } else { prnMsg(_('Failed to create database ' . $DatabaseName . ' and the error is ' . ' ' . mysql_error($Db)), 'error'); } }
<?php # Oppening connection with the database. $connection = mysql_connect("localhost", "root", "root"); if (!$connection) { die("<p>The database server is not available</p>" . "<p>Error code: " . mysql_connect_errno() . ": " . mysql_connect_error() . "</p>"); } # Selecting a database. $database = mysql_select_db("trabalhos", $connection); if (!$database) { die("<p>It was not possible to select the database</p>" . "<p>Error code: " . mysql_errno($connection) . ": " . mysql_error($connection) . "<br />"); } # Used to store students and their grades. $students_array = array(); # Used to get the max number of exercices. $max = getMaxNumberOfExercises(); # Used to calculate the grade for each student. calculateGrade($max); function getMaxNumberOfExercises() { $max = 0; # Getting all students in the database. $query = "SELECT ALUNOS.matricula FROM ALUNOS"; $students = mysql_query($query); while ($row = mysql_fetch_array($students)) { # Useful for getting a specific student's homework. $matricula = $row["matricula"]; # Getting the number of all correct homework of a specific student. $queryCountCorret = "SELECT COUNT(*)\n FROM TRABALHOS \n WHERE TRABALHOS.aluno = {$matricula}"; $countCorrect = mysql_query($queryCountCorret); # Getting the numeric result.
<?php $con = mysqli_connect("localhost", "root", "root"); if (mysqli_connect_errno($connect)) { echo "Failed to connect to MySQL: " . mysql_connect_error(); } else { echo "success"; } // If the value is set, then assign the value from the Android program, otherwise die and send error message. $value = isset($_POST['value']) ? $_POST['value'] : die('No data sent'); $query = mysqli_query($connect, "insert into profiles(columnName) values ('{$value}') "); mysqli_close($connect); echo "Finished";