public function getAttribute($attribute, &$source = null, $func = 'PDO::getAttribute', &$last_error = null) { if ($source == null) { $source =& $this->driver_options; } switch ($attribute) { case PDO::ATTR_AUTOCOMMIT: $result = mysqli_query($this->link, 'SELECT @@AUTOCOMMIT', MYSQLI_USE_RESULT); if (!$result) { $this->set_driver_error(null, PDO::ERRMODE_EXCEPTION, $func); } $row = mysqli_fetch_row($result); mysqli_free_result($result); return intval($row[0]); break; case PDO::ATTR_CLIENT_VERSION: return mysqli_get_client_info(); break; case PDO::ATTR_CONNECTION_STATUS: return mysqli_get_host_info($this->link); break; case PDO::ATTR_SERVER_INFO: return mysqli_stat($this->link); break; case PDO::ATTR_SERVER_VERSION: return mysqli_get_server_info($this->link); break; default: return parent::getAttribute($attribute, $source, $func, $last_error); break; } }
function dump_properties($mysqli) { printf("\nClass variables:\n"); $variables = array_keys(get_class_vars(get_class($mysqli))); sort($variables); foreach ($variables as $k => $var) { printf("%s = '%s'\n", $var, var_export(@$mysqli->{$var}, true)); } printf("\nObject variables:\n"); $variables = array_keys(get_object_vars($mysqli)); foreach ($variables as $k => $var) { printf("%s = '%s'\n", $var, var_export(@$mysqli->{$var}, true)); } printf("\nMagic, magic properties:\n"); assert(@mysqli_affected_rows($mysqli) === @$mysqli->affected_rows); printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n", @$mysqli->affected_rows, gettype(@$mysqli->affected_rows), @mysqli_affected_rows($mysqli), gettype(@mysqli_affected_rows($mysqli))); assert(@mysqli_get_client_info() === @$mysqli->client_info); printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n", @$mysqli->client_info, gettype(@$mysqli->client_info), @mysqli_get_client_info(), gettype(@mysqli_get_client_info())); assert(@mysqli_get_client_version() === @$mysqli->client_version); printf("mysqli->client_version = '%s'/%s ('%s'/%s)\n", @$mysqli->client_version, gettype(@$mysqli->client_version), @mysqli_get_client_version(), gettype(@mysqli_get_client_version())); assert(@mysqli_errno($mysqli) === @$mysqli->errno); printf("mysqli->errno = '%s'/%s ('%s'/%s)\n", @$mysqli->errno, gettype(@$mysqli->errno), @mysqli_errno($mysqli), gettype(@mysqli_errno($mysqli))); assert(@mysqli_error($mysqli) === @$mysqli->error); printf("mysqli->error = '%s'/%s ('%s'/%s)\n", @$mysqli->error, gettype(@$mysqli->error), @mysqli_error($mysqli), gettype(@mysqli_error($mysqli))); assert(@mysqli_field_count($mysqli) === @$mysqli->field_count); printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n", @$mysqli->field_count, gettype(@$mysqli->field_count), @mysqli_field_count($mysqli), gettype(@mysqli_field_count($mysqli))); assert(@mysqli_insert_id($mysqli) === @$mysqli->insert_id); printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n", @$mysqli->insert_id, gettype(@$mysqli->insert_id), @mysqli_insert_id($mysqli), gettype(@mysqli_insert_id($mysqli))); assert(@mysqli_sqlstate($mysqli) === @$mysqli->sqlstate); printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n", @$mysqli->sqlstate, gettype(@$mysqli->sqlstate), @mysqli_sqlstate($mysqli), gettype(@mysqli_sqlstate($mysqli))); assert(@mysqli_get_host_info($mysqli) === @$mysqli->host_info); printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n", @$mysqli->host_info, gettype(@$mysqli->host_info), @mysqli_get_host_info($mysqli), gettype(@mysqli_get_host_info($mysqli))); /* note that the data types are different */ assert(@mysqli_info($mysqli) == @$mysqli->info); printf("mysqli->info = '%s'/%s ('%s'/%s)\n", @$mysqli->info, gettype(@$mysqli->info), @mysqli_info($mysqli), gettype(@mysqli_info($mysqli))); assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id); assert(gettype(@$mysqli->thread_id) == gettype(@mysqli_thread_id($mysqli))); printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n", @$mysqli->thread_id, gettype(@$mysqli->thread_id), @mysqli_thread_id($mysqli), gettype(@mysqli_thread_id($mysqli))); assert(@mysqli_get_proto_info($mysqli) === @$mysqli->protocol_version); printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n", @$mysqli->protocol_version, gettype(@$mysqli->protocol_version), @mysqli_get_proto_info($mysqli), gettype(@mysqli_get_proto_info($mysqli))); assert(@mysqli_get_server_info($mysqli) === @$mysqli->server_info); printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n", @$mysqli->server_info, gettype(@$mysqli->server_info), @mysqli_get_server_info($mysqli), gettype(@mysqli_get_server_info($mysqli))); assert(@mysqli_get_server_version($mysqli) === @$mysqli->server_version); printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n", @$mysqli->server_version, gettype(@$mysqli->server_version), @mysqli_get_server_version($mysqli), gettype(@mysqli_get_server_version($mysqli))); assert(@mysqli_warning_count($mysqli) === @$mysqli->warning_count); printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n", @$mysqli->warning_count, gettype(@$mysqli->warning_count), @mysqli_warning_count($mysqli), gettype(@mysqli_warning_count($mysqli))); printf("\nAccess to undefined properties:\n"); printf("mysqli->unknown = '%s'\n", @$mysqli->unknown); @($mysqli->unknown = 13); printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown); $unknown = 'friday'; @($mysqli->unknown = $unknown); printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown); printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n"); assert(@mysqli_connect_error() === @$mysqli->connect_error); printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n", @$mysqli->connect_error, gettype(@$mysqli->connect_error), @mysqli_connect_error(), gettype(@mysqli_connect_error())); assert(@mysqli_connect_errno() === @$mysqli->connect_errno); printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n", @$mysqli->connect_errno, gettype(@$mysqli->connect_errno), @mysqli_connect_errno(), gettype(@mysqli_connect_errno())); }
/** * get_host() * * returns database host */ function get_host() { if ($this->dbh) { return mysqli_get_host_info($this->dbh); } else { return "Error: Not connected to a database."; } }
function get_details() { $result = $this->_owner->query('SHOW VARIABLES', false, true); while ($row = $result->fetch_row()) { $details[$row[0]] = $row[1]; } $result->free(); $details['engine'] = 'MySQLi'; $details['client'] = mysqli_get_client_info(); $details['server'] = $this->_owner->connect_id->server_info; $details['unicode'] = version_compare($details['server'], '4.1') >= 0; $details['host'] = mysqli_get_host_info($this->_owner->connect_id); return $details; }
function bddConnect() { $host = 'db576985956.db.1and1.com'; $user = '******'; $pw = 'raziel63'; $dbname = 'db576985956'; $link = mysqli_connect($host, $user, $pw, $dbname); if (mysqli_connect_error()) { die('Erreur de connexion (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } echo 'Seko... ' . mysqli_get_host_info($link) . "\n"; return $link; exit; }
static function Conn() { include '../config/includes/config.php'; //conexão nova usando mysqli //versão nova $conn = new mysqli($hostname, $usuario, $senha, $db); if (!$conn) { echo "Error: Unable to connect to MySQL." . PHP_EOL; echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; echo "Debugging error: " . mysqli_connect_error() . PHP_EOL; exit; } echo "Successo: A conexao SQL funcionou! A conexao ao banco de dados está bom. <br>"; echo "Host information: " . mysqli_get_host_info($conn) . "<br>"; //definir transações em utf8 $conn->set_charset('utf8'); return $conn; //mysqli_close($link); }
<!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <title>Saludo</title> </head> <body> <?php echo 'Primera linea <br />'; echo 'Segunda Linea <br />'; $conexion = mysqli_connect('localhost', 'konectia', 'konectia', 'konectia', 3306); if (!$conexion) { echo "Error: No se pudo conectar a MySQL." . PHP_EOL; echo "errno de depuración: " . mysqli_connect_errno() . PHP_EOL; echo "error de depuración: " . mysqli_connect_error() . PHP_EOL; exit; } echo "Éxito: Se realizó una conexión apropiada a MySQL! La base de datos 'konectia' es genial." . PHP_EOL; echo "Información del host: " . mysqli_get_host_info($conexion) . PHP_EOL; $resultado = $conexion->query("SELECT * FROM clientes"); echo mysqli_affected_rows($resultado); mysqli_close($conexion); ?> </body> </html>
<?php require_once "connect.inc"; if (!is_null($tmp = @mysqli_get_host_info())) { printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); } if (!is_null($tmp = @mysqli_get_host_info(NULL))) { printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); } require "table.inc"; if (!is_string($info = mysqli_get_host_info($link)) || '' === $info) { printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); } if ($IS_MYSQLND && $host != 'localhost' && $host != '127.0.0.1' && $port != '' && $host != "" && strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { /* this should be a TCP/IP connection and not a Unix Socket (or SHM or Named Pipe) */ if (!stristr($info, "TCP/IP")) { printf("[004] Should be a TCP/IP connection but mysqlnd says '%s'\n", $info); } } print "done!";
<?php session_start(); require_once '/var/www/vhosts/theexecutivesguild.org/master_includes.php'; $db = mysqli_connect(HOST, USER, PASSWORD, DBASE); if (!$db) { echo "<p>Error: Unable to connect to MySQL." . PHP_EOL; echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; echo "Debugging error: " . mysqli_connect_error() . PHP_EOL . '</p>'; exit; } echo "<!--Success: A proper connection to MySQL was made! The database is great." . PHP_EOL; echo "Host information: " . mysqli_get_host_info($db) . PHP_EOL . '-->'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: EGL Meeting Module <*****@*****.**>' . "\r\n"; $headers .= 'Bcc: webmaster@artisticdigital.com' . "\r\n"; //mail('*****@*****.**', 'test cron','test'); //GET MEETINGS $q = "SELECT * FROM meeting_events WHERE meeting_date > curdate() ORDER BY meeting_date ASC"; $result = $db->query($q); while ($data = $result->fetch_object()) { $meetings[] = $data; } //GET MEMBERS $q = "SELECT * FROM members WHERE mActive=1 order by mLName"; $result = $db->query($q); while ($data = $result->fetch_object()) { $members[] = $data; } foreach ($meetings as $meeting) {
echo "\t</tr>"; echo "\t<tr>"; echo "\t\t<td><b>PHP version: </b></td>"; echo "\t\t<td>" . phpversion() . "</td>"; echo "\t</tr>"; echo "\t<tr>"; echo "\t\t<td><b>PHP connection: </b></td>"; echo "\t\t<td>" . php_sapi_name() . "</td>"; echo "\t</tr>"; echo "\t<tr>"; echo "\t\t<td><b>MySQL version: </b></td>"; echo "\t\t<td>" . mysqli_get_server_info($conn) . "</td>"; echo "\t</tr>"; echo "\t<tr>"; echo "\t\t<td><b>MySQL connection: </b></td>"; echo "\t\t<td>" . mysqli_get_host_info($conn) . "</td>"; echo "\t</tr>"; echo "\t<tr>"; echo "\t\t<td><b>Current memory usage: </b></td>"; echo "\t\t<td>" . memory_get_usage() . " bytes</td>"; echo "\t</tr>"; echo "\t<tr>"; echo "\t\t<td><b>Peak memory usage: </b></td>"; echo "\t\t<td>" . memory_get_peak_usage(True) . " bytes</td>"; echo "\t</tr>"; echo "</table>"; ?> </div> <div id="table"> <?php $query = "\tshow tables";
/** * Returns a string representing the type of connection used * @uses mysqli_get_host_info() * @uses $GLOBALS['userlink'] as default for $link * @param resource $link mysql link * @return string type of connection used */ function PMA_DBI_get_host_info($link = null) { if (null === $link) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; } else { return false; } } return mysqli_get_host_info($link); }
<?php ini_set('auto_detect_line_endings', TRUE); //make script safe after use by killing b4 it starts die("script stopped to avoid unsafe execution"); $file = 'nhifp12.txt'; $handle = fopen($file, 'r'); // print_r($handle); $dblink = mysqli_connect('localhost', 'root', 'r00t', 'nhif'); if (!$dblink) { die('Could not connect ' . mysqli_connect_errno() . ': ' . mysqli_connect_error()); } echo "<br> Successful connection to " . mysqli_get_host_info($dblink); //print_r($handle); // $q = mysqli_query($dblink, "select all from routes"); // var_dump($q); die(" <br> dead script"); $size = 1024; while (!feof($handle)) { while (($buffer = fgets($handle, $size)) !== false) { $buffer; $data = explode(",", $buffer); //prepare insert statement // print_r($data); $query = "INSERT INTO servicepoints (nhifservicepoint, accreditedfacilityname, county) VALUES (?, ?, ?)"; $stmt = mysqli_prepare($dblink, $query); // var_dump($query); // var_dump($stmt); // die(""); // siss = string, interger, string, string, the types of data to save in db mysqli_stmt_bind_param($stmt, 'sss', $val1, $val2, $val3);
public function mysql_server($num = '') { switch ($num) { case 1: return mysqli_get_server_info(); //MySQL 服务器信息 break; case 2: return mysqli_get_host_info(); //取得 MySQL 主机信息 break; case 3: return mysqli_get_client_info(); //取得 MySQL 客户端信息 break; case 4: return mysqli_get_proto_info(); //取得 MySQL 协议信息 break; default: return mysqli_get_client_info(); //默认取得mysql版本信息 } }
<?php $host = "localhost"; $user = "******"; $pass = "******"; $db = "mysql"; $link = mysqli_connect($host, $user, $pass, $db); /* check connection */ if (!$link) { printf("Connect failed: %s\n", mysqli_connect_error()); exit; } printf("Host information: %s\n", mysqli_get_host_info($link)); /* close connection */ mysqli_close($link); ?>
public function getServerInfo($type = null) { if ($this->conn_id && $this->state == self::OPEN) { switch ($type) { case self::CLIENT_VERSION: return mysqli_get_client_info(); break; case self::HOST_INFO: return mysqli_get_host_info($this->conn_id); break; case self::PROTOCOL_VERSION: return mysqli_get_proto_info($this->conn_id); break; case self::SERVER_VERSION: default: return mysqli_get_server_info($this->conn_id); break; } return ''; } //throw new PhPBURN_Exception() TODO CREATE EXCETION CLASS AND INPUT AN EXCEPTION HERE; }
* @author Ruud Eisinga - www.dev4me.nl * @link http://www.dev4me.nl/ * @license http://www.gnu.org/licenses/gpl.html * @platform WebsiteBaker 2.8.x * @version 0.4.1 * @lastmodified August 23, 2016 * */ // Must include code to stop this file being access directly if (defined('WB_PATH') == false) { die("Cannot access this file directly"); } if (is_object($database->DbHandle)) { $title = "MySQLi Info"; $server_info = mysqli_get_server_info($database->DbHandle); $host_info = mysqli_get_host_info($database->DbHandle); $proto_info = mysqli_get_proto_info($database->DbHandle); $client_info = mysqli_get_client_info($database->DbHandle); $client_encoding = mysqli_character_set_name($database->DbHandle); $status = explode(' ', mysqli_stat($database->DbHandle)); } else { $title = "MySQL Info"; $server_info = mysql_get_server_info(); $host_info = mysql_get_host_info(); $proto_info = mysql_get_proto_info(); $client_info = mysql_get_client_info(); $client_encoding = mysql_client_encoding(); $status = explode(' ', mysql_stat()); } $strictMode = $database->get_one('SELECT @@sql_mode'); $strict_info = (strpos($strictMode, 'STRICT_TRANS_TABLES') !== false or strpos($strictMode, 'STRICT_ALL_TABLES') !== false) ? "MySQL strict mode active" : "MySQL strict mode not active\n";
public static function get_host_information() { return mysqli_get_host_info(MySQLConnection::$db_connection); }
<?php $dbhost = 'localhost:3306'; /*nombre de servidor*/ $dbusername = '******'; /*usuario de base de datos*/ $dbuserpass = ''; /*contraseña, la deje en blanco para pruebas*/ $dbname = 'bootstrap'; /*nombre de la base de datos*/ $enlace = mysqli_connect($dbhost, $dbusername, $dbuserpass, $dbname); if (!$enlace) { print "Error: No se pudo conectar a MySQL." . PHP_EOL; print "errno de depuración: " . mysqli_connect_errno() . PHP_EOL; print "error de depuración: " . mysqli_connect_error() . PHP_EOL; exit; } print "Éxito: Se realizó una conexión apropiada a MySQL! La base de datos mi_bd es genial." . PHP_EOL; print "Información del host: " . mysqli_get_host_info($enlace) . PHP_EOL; mysqli_close($enlace);
public function getDbInfo() { $charsets = $this->getCharsetInfo(); $charset_str = array(); foreach ($charsets as $name => $value) { $charset_str[] = "{$name} = {$value}"; } return array("MySQLi Version" => @mysqli_get_client_info(), "MySQLi Host Info" => @mysqli_get_host_info($this->database), "MySQLi Server Info" => @mysqli_get_server_info($this->database), "MySQLi Client Encoding" => @mysqli_client_encoding($this->database), "MySQL Character Set Settings" => join(", ", $charset_str)); }
<?php require_once "connect.inc"; /*** test mysqli_connect 127.0.0.1 ***/ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); $hinfo = mysqli_get_host_info($link); var_dump(str_replace('/', '', $hinfo)); mysqli_close($link); print "done!";
<?php $link = mysqli_connect('localhost', 'root', ''); if (!$link) { die('Connection Error (' . mysqli_connect_errno() . ')' . mysqli_connect_error()); } echo "OK..." . mysqli_get_host_info($link) . "\n"; mysqli_close($link); ?>
/** */ function get_host_info() { return $this->db_connect_id ? mysqli_get_host_info($this->db_connect_id) : false; }
/** * Returns a string representing the type of connection used * * @param resource $link mysql link * * @return string type of connection used */ public function getHostInfo($link) { return mysqli_get_host_info($link); }
function mysql_get_host_info(\mysqli $link = null) { return mysqli_get_host_info(\Dshafik\MySQL::getConnection($link)); }
function executemysql($getinfo, $getdumps, $getschema) { //BEGIN GET DB INFO global $getDumpsFrom; global $curdatetime; global $sugar_config; global $progress_bar_percent; global $sod_guid; global $db; if ($db->dbType != "mysql") { if ($getinfo) { sodUpdateProgressBar(MYSQL_INFO_WEIGHT); } if ($getschema) { sodUpdateProgressBar(MYSQL_SCHEMA_WEIGHT); } if ($getdumps) { sodUpdateProgressBar(MYSQL_DUMPS_WEIGHT); } return; } $mysqlInfoDir = create_cache_directory("diagnostic/" . $sod_guid . "/diagnostic" . $curdatetime . "/MySQL/"); //create directory for table definitions if ($getschema) { $tablesSchemaDir = create_cache_directory("diagnostic/" . $sod_guid . "/diagnostic" . $curdatetime . "/MySQL/TableSchema/"); } //BEGIN GET MYSQL INFO //make sure they checked the box to get basic info if ($getinfo) { ob_start(); echo "MySQL Version: " . (function_exists('mysqli_get_client_info') ? @mysqli_get_client_info() : @mysql_get_client_info()) . "<BR>"; echo "MySQL Host Info: " . (function_exists('mysqli_get_host_info') ? @mysqli_get_host_info($db->getDatabase()) : @mysql_get_host_info()) . "<BR>"; echo "MySQL Server Info: " . (function_exists('mysqli_get_client_info') ? @mysqli_get_client_info() : @mysql_get_client_info()) . "<BR>"; echo "MySQL Client Encoding: " . (function_exists('mysqli_character_set_name') ? @mysqli_character_set_name($db->getDatabase()) : @mysql_client_encoding()) . "<BR>"; /* Uncomment to get current processes as well echo "<BR>MySQL Processes<BR>"; $res = $db->query('SHOW PROCESSLIST'); echo "<table border=\"1\"><tr><th>Id</th><th>Host</th><th>db</th><th>Command</th><th>Time</th></tr>"; if($db->getRowCount($res) > 0) { while($row = $db->fetchByAssoc($res)) { printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>", $row['Id'], $row['Host'], $row['db'], $row['Command'], $row['Time'] ); } echo "</table><br>"; } else { echo "</table>"; echo "No processes running<br>"; } */ echo "<BR>MySQL Character Set Settings<BR>"; $res = $db->query("show variables like 'character\\_set\\_%'"); echo "<table border=\"1\"><tr><th>Variable Name</th><th>Value</th></tr>"; while ($row = $db->fetchByAssoc($res)) { printf("<tr><td>%s</td><td>%s</td></tr>", $row['Variable_name'], $row['Value']); } echo "</table>"; $content = ob_get_contents(); ob_clean(); $handle = sugar_fopen($mysqlInfoDir . "MySQL-General-info.html", "w"); if (fwrite($handle, $content) === FALSE) { echo "Cannot write to file " . $mysqlInfoDir . "_MySQL-General-info.html<br>"; } fclose($handle); //BEGIN UPDATING PROGRESS BAR sodUpdateProgressBar(MYSQL_INFO_WEIGHT); //END UPDATING PROGRESS BAR } //END GET MYSQL INFO if ($getschema) { //BEGIN GET ALL TABLES SCHEMAS $all_tables = $db->getTablesArray(); global $theme_path; ob_start(); echo "<style>"; echo file_get_contents($theme_path . "style.css"); echo "</style>"; foreach ($all_tables as $tablename) { //setting up table header for each file echo "<table border=\"0\" cellpadding=\"0\" class=\"tabDetailView\">"; echo "<tr>MySQL " . $tablename . " Definitions:</tr>" . "<tr><td class=\"tabDetailViewDL\"><b>Field</b></td>" . "<td class=\"tabDetailViewDL\">Type</td>" . "<td class=\"tabDetailViewDL\">Null</td>" . "<td class=\"tabDetailViewDL\">Key</td>" . "<td class=\"tabDetailViewDL\">Default</td>" . "<td class=\"tabDetailViewDL\">Extra</td></tr>"; $describe = $db->query("describe " . $tablename); while ($inner_row = $db->fetchByAssoc($describe)) { $inner_row = array_values($inner_row); echo "<tr><td class=\"tabDetailViewDF\"><b>" . $inner_row[0] . "</b></td>"; echo "<td class=\"tabDetailViewDF\">" . $inner_row[1] . "</td>"; echo "<td class=\"tabDetailViewDF\">" . $inner_row[2] . "</td>"; echo "<td class=\"tabDetailViewDF\">" . $inner_row[3] . "</td>"; echo "<td class=\"tabDetailViewDF\">" . $inner_row[4] . "</td>"; echo "<td class=\"tabDetailViewDF\">" . $inner_row[5] . "</td></tr>"; } echo "</table>"; echo "<BR><BR>"; } $content = ob_get_contents(); ob_clean(); $handle = sugar_fopen($tablesSchemaDir . "MySQLTablesSchema.html", "w"); if (fwrite($handle, $content) === FALSE) { echo "Cannot write to file " . $tablesSchemaDir . "MySQLTablesSchema.html<br>"; } fclose($handle); //END GET ALL TABLES SCHEMAS //BEGIN UPDATING PROGRESS BAR sodUpdateProgressBar(MYSQL_SCHEMA_WEIGHT); //END UPDATING PROGRESS BAR } if ($getdumps) { //BEGIN GET TABLEDUMPS $tableDumpsDir = create_cache_directory("diagnostic/" . $sod_guid . "/diagnostic" . $curdatetime . "/MySQL/TableDumps/"); foreach ($getDumpsFrom as $table) { ob_start(); //calling function defined above to get the string for dump echo getFullTableDump($table); $content = ob_get_contents(); ob_clean(); $handle = sugar_fopen($tableDumpsDir . $table . ".html", "w"); if (fwrite($handle, $content) === FALSE) { echo "Cannot write to file " . $tableDumpsDir . $table . "html<br>"; } fclose($handle); } //END GET TABLEDUMPS //BEGIN UPDATING PROGRESS BAR sodUpdateProgressBar(MYSQL_DUMPS_WEIGHT); //END UPDATING PROGRESS BAR } //END GET DB INFO }
<?php // me conecto al servidor y a la base de datos $link = mysqli_connect('localhost', 'root', '', 'webimage'); if (!$link) { die('Error de Conexión (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } echo 'Exito... ' . mysqli_get_host_info($link) . "\n"; //mysqli_close($link); //obtenemos los valores del formulario $nombre = $_POST['nombre']; $apellido = $_POST['apellido']; $usuario = $_POST['usuario']; $password = $_POST['password']; $sql = "INSERT INTO usuarios (nombre, apellido,usuario,password)\nVALUES ('{$nombre}', '{$apellido}', '{$usuario}','{$password}')"; if (mysqli_query($link, $sql)) { echo '<br> New record created successfully <a href="login.html"> Logearse</a>'; } else { echo "Error: " . $sql . "<br>" . mysqli_error($link); } //mysqli_real_query ($link , string INSERT INTO usuarios(nombre, apellido, usuario, password) VALUES($nombre, $apellido, $usuario, $password) or die (<h2>Error de envio de datos a la tabla</h2>); //echo ' //<h2>Registro completo</h2> //<a href="login.html"> Logearse</a> //'; /**if(mysql_query($query))$q=1; else $q=0; if($q==1){ $result = mysql_result($q, 0);
$host = "127.0.0.1"; $user = "******"; $pass = "******"; $db = "my-db"; /* MYSQL_ROOT_PASSWORD=xpto */ $link = mysqli_connect($host, $user, $pass, $db); if (!$link) { echo "Error: Unable to connect to MySQL." . PHP_EOL; echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; echo "Debugging error: " . mysqli_connect_error() . PHP_EOL; exit; } echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL; echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL; mysqli_close($link); $r = mysqli_connect($host, $user, $pass, $db); if (!$r) { echo "Could not connect to server\n"; trigger_error(mysql_error(), E_USER_ERROR); } else { echo "Connection established" . PHP_EOL; } $mysqli = new mysqli($host, $user, $pass, $db); /* * This is the "official" OO way to do it, * BUT $connect_error was broken until PHP 5.2.9 and 5.3.0. */ if ($mysqli->connect_error) { die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
function info() { return mysqli_get_host_info($this->LinkID); }
/** * debuger * * @param boolean $log2file * @param mixed $debugFile */ public function debug($log2file = false, $debugFile = false) { if ($log2file == 'off') { if (is_object($this->debug)) { $this->debug->getLog(); $this->debug = false; } } else { $debugFile = $debugFile ?: (defined('DALMP_DEBUG_FILE') ? DALMP_DEBUG_FILE : '/tmp/dalmp.log'); $this->debug = new Logger($log2file, $debugFile); $this->debug->log('DSN', $this->dsn); if ($this->isConnected()) { $this->debug->log('DALMP', mysqli_get_host_info($this->DB), 'protocol version: ' . mysqli_get_proto_info($this->DB), 'character set: ' . mysqli_character_set_name($this->DB)); } } return; }
function mysql_get_host_info($c = null) { if (($c = mysql_global_resource($c, 1 - func_num_args())) == null) { return; } return mysqli_get_host_info($c); }