本文整理汇总了PHP中mysqli_error函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_error函数的具体用法?PHP mysqli_error怎么用?PHP mysqli_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_user
function check_user($uid, $link)
{
$query = "SELECT sid FROM " . USERS_TABLE . " WHERE uid='{$uid}';";
$result = mysqli_query($link, $query) or die(mysqli_error());
$row = mysqli_fetch_assoc($result);
return $row["sid"] == SID ? true : false;
}
示例2: mySqlUpit
function mySqlUpit($upit, $tip)
{
$konekcija = mysqli_connect("localhost", "root", "", "0007cinevision");
$konekcija->set_charset("utf8");
if (mysqli_connect_errno()) {
printf("Konekcija nije uspela: %s\n", mysqli_connect_error());
exit;
}
$rezultat = mysqli_query($konekcija, $upit);
if (!$rezultat) {
printf("Greska: %s\n", mysqli_error($konekcija));
exit;
}
if ($tip == 0) {
return 0;
}
if ($tip == 1) {
$rez = mysqli_fetch_array($rezultat, MYSQLI_NUM);
$konekcija->close();
} else {
if ($tip == 2) {
$rez = array();
$i = 0;
while (($red = mysqli_fetch_array($rezultat)) != NULL) {
$rez[$i++] = $red;
}
}
}
if (!empty($rez)) {
return $rez;
}
return -1;
}
示例3: bajaEmpleo
public function bajaEmpleo($id)
{
$conexion = new Conexion();
$sql = "delete from empleos_anteriores where id={$id}";
mysqli_query($conexion->link, $sql) or die("Error: " . mysqli_error($conexion->link));
echo "Empleo borrado correctamente";
}
示例4: query
/**
* @param $sql string
* // todo: add fetch types
* @param string $fetch_type string [assoc, object, ...]
* @return array
*/
public function query($sql, $fetch_type = 'assoc')
{
// todo: check sql string
$this->mysqli->query($sql);
$rows = array();
$result = $this->mysqli->query($sql);
if (!$result) {
$this->loger->addLog(LOG_ERR, mysqli_error($this->mysqli));
// todo: goto html output
die;
}
switch ($fetch_type) {
default:
case 'assoc':
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
break;
case 'object':
while ($row = $result->fetch_object()) {
$rows[] = $row;
}
break;
}
return $rows;
}
示例5: open_connection
public function open_connection()
{
$this->connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_DBNAME);
if (!$this->connection) {
die("Database Connection Failed " . mysqli_error());
}
}
示例6: getDatosAnteriores
function getDatosAnteriores($nombreUsuario)
{
$datos = array();
if ($connect = mysqli_connect("localhost", "root", "", "prueba1")) {
$sql_select = sprintf("select Nombre,Apellidos,Fecha_Nacimiento,DNI,Localidad,Provincia,CP,Telefono from datos_usuarios\r\n\t\t\t\t\t\t\tinner join credenciales on datos_usuarios.ID_Credenciales=credenciales.idCredenciales\r\n\t\t\t\t\t\t\twhere credenciales.Usuario= '%s';", $nombreUsuario);
//echo $sql_select."</br>";
$resultado_queryDatos = mysqli_query($connect, $sql_select);
if ($resultado_queryDatos == FALSE) {
echo "Error al ejecutar la consulta:</br>";
echo mysqli_error($resultado_queryDatos) . "</br>";
} else {
if (mysqli_num_rows($resultado_queryDatos) == 1) {
$i = 0;
$registro = mysqli_fetch_row($resultado_queryDatos);
while ($i <= 7) {
//echo $i." ".$registro[$i]."</br>";
$datos[$i] = $registro[$i];
$i++;
}
return $datos;
} else {
echo "El resultado es diferente uno";
return false;
}
}
} else {
echo "Error al conectar con BBDD </br>";
return false;
}
}
示例7: queryToArray
public static function queryToArray($sql)
{
global $my_user, $my_pass, $my_host, $my_db, $config_enable_cache;
$link = Database::getLink();
$db_selected = mysqli_select_db($link, $my_db);
if (!$db_selected) {
die('Can\'t use ' . $my_db . ' : ' . mysqli_error($link));
}
// Perform Query
$result = mysqli_query($link, $sql);
$id = mysqli_insert_id($link);
if ($id > 0) {
// we did an insert, just return the id
return $id;
}
//echo ("\ndatabase qtoa before proc id is $id");
if (!$result) {
$message = 'Invalid query: ' . mysqli_error($link) . "\n";
$message .= 'Whole query: ' . $sql;
die($message);
}
if ($result === true) {
// probably an insert..
return false;
}
$rows = array();
while ($row = mysqli_fetch_assoc($result)) {
$rows[] = $row;
}
return $rows;
}
示例8: query
public function query($sql, $unbuffered = false)
{
if (defined('FEATHER_SHOW_QUERIES')) {
$q_start = get_microtime();
}
$this->query_result = @mysqli_query($this->link_id, $sql);
if ($this->query_result) {
if (defined('FEATHER_SHOW_QUERIES')) {
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
}
++$this->num_queries;
return $this->query_result;
} else {
if (defined('FEATHER_SHOW_QUERIES')) {
$this->saved_queries[] = array($sql, 0);
}
$this->error_no = @mysqli_errno($this->link_id);
$this->error_msg = @mysqli_error($this->link_id);
// Rollback transaction
if ($this->in_transaction) {
mysqli_query($this->link_id, 'ROLLBACK');
}
--$this->in_transaction;
return false;
}
}
示例9: onSQLReady
function onSQLReady($db_sock)
{
$db_res = $this->busy_pool[$db_sock];
$mysqli = $db_res['mysqli'];
$fd = $db_res['fd'];
echo __METHOD__ . ": client_sock={$fd}|db_sock={$db_sock}\n";
if ($result = $mysqli->reap_async_query()) {
$ret = var_export($result->fetch_all(MYSQLI_ASSOC), true) . "\n";
//var_dump($ret);
$this->serv->send($fd, $ret);
if (is_object($result)) {
mysqli_free_result($result);
}
} else {
$this->serv->send($fd, sprintf("MySQLi Error: %s\n", mysqli_error($mysqli)));
}
//release mysqli object
$this->idle_pool[] = $db_res;
unset($this->busy_pool[$db_sock]);
//这里可以取出一个等待请求
if (count($this->wait_queue) > 0) {
$idle_n = count($this->idle_pool);
for ($i = 0; $i < $idle_n; $i++) {
$req = array_shift($this->wait_queue);
$this->doQuery($req['fd'], $req['sql']);
}
}
}
示例10: autorization
/**
* @param $login
* @param $pass
* @return bool|mysqli_result
*/
public function autorization($login, $pass)
{
//method to check user login data in database
//db_connect() - connect to database - method from parent class Config_db
$query = mysqli_query($this->db_connect(), "SELECT * FROM user_reg WHERE login='{$login}' AND pass='{$pass}'") or die(mysqli_error($this->db_connect()));
return $query;
}
示例11: getRank
function getRank($a, $b, $c)
{
include 'config.php';
$con = mysqli_connect($IP, $user, $pass, $db);
// echo "select `idCategory` from Placed where `idBid`=$c and `idAuction`=$a";
// echo "select `idCategory` from Placed where `idBid`=$c and `idAuction`=$a";
//echo "select `idCategory` from Placed where `idBid`=$c and `idAuction`=$a";
// $result=mysqli_query($con,"select `idCategory` from Placed where `idBid`=$c and `idAuction`=$a") or die(mysqli_error($con));
$result = mysqli_query($con, "select `idCategory` from Placed where `idBid`={$c} and `idAuction`={$a}") or die(mysqli_error($con));
// echo "select count(*)+1 as rank from Placed where `Price`>$b and `idAuction`=$a and `status` = 'A'";
// echo json_encode($result);
// echo mysqli_num_rows($result);
$row = mysqli_fetch_assoc($result);
$c = $row['idCategory'];
// echo $c.'sdf';
if (empty($c)) {
return 0;
}
// echo "select count(*)+1 as rank from Placed where `Price`>$b and `idCategory`=$c and `idAuction`=$a and `status` = 'A'";
//echo "select count(*)+1 as rank from Placed where `Price`>$b and `idCategory`=$c and `idAuction`=$a and `status` = 'A'";
$result = mysqli_query($con, "select count(*)+1 as rank from Placed where `Price`>{$b} and `idCategory`={$c} and `idAuction`={$a} and `status` = 'A'") or die("Error" . mysqli_error($con));
$output = [];
while ($row = mysqli_fetch_assoc($result)) {
return $row['rank'];
}
}
示例12: trans
public function trans()
{
if (!\mysqli_begin_transaction($this->connection, MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT)) {
throw new \Exception('Could not start Transaction: ' . \mysqli_error($this->connection));
}
return true;
}
示例13: delete
public function delete($id)
{
$Blog = new Blog($this->plural_resource);
$sql = $Blog->destroy($id);
mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
header("Location: ../index");
}
示例14: check_db
function check_db($dbhost, $dbuser, $dbpw, $dbname, $tablepre)
{
if (!function_exists('mysql_connect') && !function_exists('mysqli_connect')) {
show_msg('undefine_func', 'mysql_connect', 0);
}
$mysqlmode = function_exists('mysql_connect') ? 'mysql' : 'mysqli';
$link = $mysqlmode == 'mysql' ? @mysql_connect($dbhost, $dbuser, $dbpw) : new mysqli($dbhost, $dbuser, $dbpw);
if (!$link) {
$errno = $mysqlmode == 'mysql' ? mysql_errno() : mysqli_errno();
$error = $mysqlmode == 'mysql' ? mysql_error() : mysqli_error();
if ($errno == 1045) {
show_msg('database_errno_1045', $error, 0);
} elseif ($errno == 2003) {
show_msg('database_errno_2003', $error, 0);
} else {
show_msg('database_connect_error', $error, 0);
}
} else {
if ($query = $mysqlmode == 'mysql' ? @mysql_query("SHOW TABLES FROM {$dbname}") : $link->query("SHOW TABLES FROM {$dbname}")) {
if (!$query) {
return false;
}
while ($row = $mysqlmode == 'mysql' ? mysql_fetch_row($query) : $query->fetch_row()) {
if (preg_match("/^{$tablepre}/", $row[0])) {
return false;
}
}
}
}
return true;
}
示例15: login
function login($username, $password)
{
$sql = mysqli_query($this->connect, "SELECT * FROM `register` WHERE `username`='{$username}' and `password`='{$password}'") or die(mysqli_error());
if (mysqli_num_rows($sql) > 0) {
return true;
}
}