Exemple #1
0
<?php

$mysqli = @new mysqli('localhost', 'admin', 'pass', 'dbtest');
require "../../library/dhtmlsql.php";
$db = DHTMLSQL::get()->connect($mysqli);
if (!$db->connected()) {
    exit("Unable to connect to database");
}
//Sets MySQL character set and collation
$db->set_charset('utf8', 'utf8_general_ci');
echo "Database connection was successful<br/><br/>";
Exemple #2
0
<?php

require "../../library/dhtmlsql.php";
// Connection data (server_address, database, name, poassword)
$dbhost = 'localhost';
$dbname = 'dbtest';
$dbuser = '******';
$dbpass = '******';
//attempt connection to database
new DHTMLSQL();
$db = DHTMLSQL::get()->connect($dbhost, $dbuser, $dbpass, $dbname);
//testing for connection to database
if (!$db->connected()) {
    exit("Unable to connect to database");
}
//Sets MySQL character set and collation
$db->set_charset('utf8', 'utf8_general_ci');
echo "Database connection was successful<br/><br/>";