当前位置: 首页>>代码示例>>PHP>>正文


PHP mysqli::connect_error方法代码示例

本文整理汇总了PHP中mysqli::connect_error方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli::connect_error方法的具体用法?PHP mysqli::connect_error怎么用?PHP mysqli::connect_error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysqli的用法示例。


在下文中一共展示了mysqli::connect_error方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dbconnect

function dbconnect($config_arr)
{
    $ads_db = new mysqli($config_arr['server_name'], $config_arr['user_name'], $config_arr['password'], $config_arr['database']);
    //устанавливаем соденинение
    if ($ads_db->connect_errno > 0) {
        die('Unable to connect' . $ads_db->connect_error() . '<a href="./install.php">You might want to install it first </a>');
    }
    if (!$ads_db->set_charset("utf8")) {
        die('Error while applying utf8 charset:  ' . $ads_db->error);
    }
    return $ads_db;
}
开发者ID:Anatoliy-Bezhenaru,项目名称:xaver.loc,代码行数:12,代码来源:L9additional.php

示例2: mysqli

 function db_connect()
 {
     // DEBUG MODE:
     //mysqli_report(MYSQLI_REPORT_ALL);
     global $GlobalConfig, $mysqli;
     $mysqli = new mysqli($GlobalConfig->dbserver, $GlobalConfig->dbuser, $GlobalConfig->dbpass, $GlobalConfig->dbname);
     if (!$mysqli) {
         dead("Connect failed: " . $mysqli->connect_error());
     } else {
         $this->db_mysql_query('SET NAMES utf8', 'db_connect');
     }
 }
开发者ID:reedy,项目名称:AutoWikiBrowserUsageStats,代码行数:12,代码来源:MySQL.php

示例3: connect

function connect()
{
    global $conn;
    $servername = "localhost";
    $username = "root";
    $password = "getready4";
    $dbname = "MiniProject";
    $conn = new mysqli($servername, $username, $password, $dbname);
    if ($conn->connect_errno) {
        die("<div class=\"alert alert-danger\" role=\"alert\">Connection failed: " . $conn->connect_error() . "</div>");
    }
}
开发者ID:aman-gupta-1995,项目名称:room-booking-system,代码行数:12,代码来源:cnntdb.php

示例4: reconnect

 /**
  * Reconnect to the db server
  */
 public function reconnect()
 {
     if (isset($this->native) && @$this->native->ping()) {
         return;
     }
     $native = new mysqli($this->settings['host'], $this->settings['user'], $this->settings['password'], $this->settings['dbname'], $this->settings['port'], $this->settings['unix_socket']);
     if (!$native) {
         throw new DB_Exception("Connecting to mysql database failed: " . \mysqli::connect_error());
     }
     $this->native = $native;
 }
开发者ID:jasny,项目名称:Q,代码行数:14,代码来源:MySQL.php

示例5: mysqli

<?php

//session_set_cookie_params(0);
session_start();
$name = $_POST['name'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$email = $_POST['email'];
$id = $_POST['id'];
$usr = $_POST['Username'];
$conn = new mysqli("localhost", "root", "", "accessit");
if ($conn->connect_error) {
    die("connection failed " . $conn->connect_error());
}
$stmt = $conn->prepare("insert into user (id,Name,PhoneNo,Address,Email) values (?,?,?,?,?)");
$stmt->bind_param("isiss", $id, $name, $phone, $address, $email);
$stmt->execute();
$_SESSION['id'] = $id;
$_SESSION['Username'] = $usr;
header("location:onlogin.php");
开发者ID:Anugrahaa,项目名称:contactbackup,代码行数:20,代码来源:addcontact.php

示例6: mysqli

<?php

//Konexioa egin datu-basearekin
//$link = new mysqli("localhost","root","","quiz");
$link = new mysqli("mysql.hostinger.es", "u526113874_rb15", "123456789", "u526113874_quiz");
if ($link->connect_errno) {
    die("Huts egin du konexioak MySQL-ra: (" . $link->connect_errno() . ") " . $link->connect_error());
}
$balioak = $link->query("Select * from galdera");
?>

<!DOCTYPE html>
<html>
	<head>
		<meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">
		<title>Sign Up</title>
		<link rel="stylesheet" type="text/css" href="stylesPWS/estiloa.css"/>
		<link rel='stylesheet' 
		   type='text/css' 
		   media='only screen and (max-width: 480px)'
		   href='stylesPWS/smartphone.css' />
		<script type="text/javascript" language="javascript" src="funtzioak.js">
		</script>
	</head>
	<body>
		<div class ="nav" id="nav">
			<ul>
				<li class ="ezkerra"><a href ="layout.html">Home</a></li>
				<li class ="ezkerra"><a href ="credits.html">Credits</a></li>
				<li class ="ezkerra"><a href ="quiz.php">Quizzes</a></li>
			</ul>
开发者ID:BZaldua,项目名称:WebSistemak,代码行数:31,代码来源:reviewingQuizzes.php

示例7: json_encode

<?php

ini_set("display_errors", On);
error_reporting(E_ALL);
mb_language("uni");
mb_internal_encoding("utf-8");
mb_http_input("auto");
mb_http_output("utf-8");
require "constant.php";
//?id=ほげほげ で指定する!
if (isset($_GET['id'])) {
    $cont_id = $_GET['id'];
}
$sql = "SELECT contribution.id, user.name, user.img, reaction.reaction, reaction.created_at FROM reaction INNER JOIN user ON reaction.user_id = user.id INNER JOIN contribution ON reaction.cont_id = contribution.id WHERE contribution.id=" . $cont_id . " ORDER BY created_at";
$link = new mysqli("localhost", "{$db_usr}", "{$db_pwd}", "{$db_name}");
$link->set_charset('utf8');
if (mysqli_connect_errno()) {
    printf("connect failed: %s\n", $link->connect_error());
    exit;
}
$user = array();
if ($result = mysqli_query($link, $sql)) {
    while ($row = mysqli_fetch_object($result)) {
        $user[] = array('id' => $row->id, 'name' => $row->name, 'img' => $row->img, 'reaction' => $row->reaction, 'created_at' => $row->created_at);
    }
    mysqli_free_result($result);
}
header('Content-type: application/json');
echo json_encode($user);
mysqli_close($link);
开发者ID:saison,项目名称:recru,代码行数:30,代码来源:reaction_post.php

示例8: arraydb

    return $rowdb;
}
//Fungsi Fetch_Array
function arraydb($sql)
{
    $arraydb = mysqli_fetch_array($sql);
    return $arraydb;
}
//Fungsi Nums_Row
function numrows($sql)
{
    $numrows = mysqli_num_rows($sql);
    return $numrows;
}
//Fungsi Close Database
function closedb()
{
    global $koneksi_db;
    mysqli_close($koneksi_db);
}
function freedb($hsl)
{
    $free = mysqli_free_result($hsl);
}
/*** Koneksi dg OOP ***/
$mysqli = new mysqli($myHost, $myUser, $myPass, $myDbs);
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", $mysqli->connect_error());
    exit;
}
开发者ID:KevinYauris,项目名称:aPPLe,代码行数:31,代码来源:dbconnect.php

示例9: exit

// определяем IP
define('PAGEVISIT', $_SERVER['REQUEST_URI']);
// определяем страницу
// ***************   Проверка версии PHP и поключение к базе данных по mysql если она меньше или равна 5.2 или MysqLi ООП если она больше   ******************* //
if (PHP_VERSION <= 5.2) {
    $CONNECTION = mysql_connect(DBHOST, DBUSER, DBPASS);
    if ($CONNECTION) {
        $DATABASE = mysql_select_db(DBNAME);
    } else {
        exit(mysql_error());
    }
    $CONNECT_FUNCTION = "mysql_query";
} else {
    $CONNECTION = new mysqli(DBHOST, DBUSER, DBPASS, DBNAME);
    if (!$CONNECTION->connect_error) {
        $DATABASE = NULL;
    } else {
        exit($CONNECTION->connect_error());
    }
    $CONNECT_FUNCTION = '$CONNECTION->query';
}
// **************          Конец проверки    ********************************************************** //
ignore_user_abort(true);
// Прерывание скрипта при отсоединении клиента
$languagesCOOKIE = explode(";", strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
for ($langsCount = 0; $langsCount < count($languagesCOOKIE); $langsCount++) {
    $LANG_SPLIT = explode(",", $languagesCOOKIE[$langsCount]);
    $LANG_SPLIT[1] = strtok($LANG_SPLIT[1], '-');
    // Языки пользователя $LANG_SPLIT[1]
}
define("LANGUAGE", "ru");
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:31,代码来源:config.php

示例10: mysqli

<!DOCTYPE html>
<html>
<head>
	<?php 
include "header.php";
$conn = new mysqli("localhost", "root", "", "organizer");
if ($conn == false) {
    echo "Connection error : " . $conn->connect_error();
}
$query = "SELECT * FROM account WHERE User='{$user}'";
$result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($result)) {
    $name = $row["nama_guru"];
    $ID = $row["ID"];
    $username = $row["User"];
    $Priv = $row["Priv"];
    if ($Priv == 1) {
        $jabatan = "Guru";
    } else {
        if ($Priv == 2) {
            $jabatan = "Wakil Kepala Sekolah";
        } else {
            if ($Priv == 3) {
                $jabatan = "Kepala Sekolah";
            }
        }
    }
    $bidang = $row["Subjek"];
    $lahir = $row["tgl_lahir"];
}
?>
开发者ID:antoniosetya,项目名称:Observasi,代码行数:31,代码来源:profile.php

示例11: buildDB

 static function buildDB($menuPages)
 {
     $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
     if ($mysqli->connect_errno) {
         exit("Couldn't connect to the database." . $mysqli->connect_error());
     }
     $admin_u = DEV_NAME;
     $admin_e = DEV_EMAIL;
     $admin_p = AdminUtilities::createSaltedHash(DEV_PASS);
     $sql = "CREATE DATABASE IF NOT EXISTS `" . DB_NAME . "`\n                DEFAULT CHARACTER SET " . DEFAULT_CHARACTER_SET . " COLLATE " . DEFAULT_COLLATION . ";\n                CREATE TABLE IF NOT EXISTS `" . DB_NAME . "`.`" . DB_PREFIX . "entryMgr`\n                (\n                    `id`        INT UNSIGNED NOT NULL PRIMARY KEY auto_increment,\n                    `page`      VARCHAR(64) NOT NULL,\n                    `title`     VARCHAR(255) DEFAULT NULL,\n                    `subhead`   VARCHAR(75) DEFAULT NULL,\n                    `body`      TEXT DEFAULT NULL,\n                    `img`       VARCHAR(128) DEFAULT NULL,\n                    `imgcap`    VARCHAR(128) DEFAULT NULL,\n                    `data1`     VARCHAR(255) DEFAULT NULL,\n                    `data2`     VARCHAR(255) DEFAULT NULL,\n                    `data3`     VARCHAR(255) DEFAULT NULL,\n                    `data4`     VARCHAR(255) DEFAULT NULL,\n                    `data5`     VARCHAR(255) DEFAULT NULL,\n                    `data6`     VARCHAR(255) DEFAULT NULL,\n                    `data7`     VARCHAR(255) DEFAULT NULL,\n                    `data8`     VARCHAR(255) DEFAULT NULL,\n                    `author`    VARCHAR(64) DEFAULT '" . SITE_CONTACT_NAME . "',\n                    `created`   INT(12),\n                    INDEX(`page`),\n                    INDEX(`created`),\n                    INDEX(`title`),\n                    FULLTEXT KEY `search` (`title`,`body`,`data2`)\n                ) ENGINE=MYISAM CHARACTER SET " . DEFAULT_CHARACTER_SET . " COLLATE " . DEFAULT_COLLATION . ";\n                CREATE TABLE IF NOT EXISTS `" . DB_NAME . "`.`" . DB_PREFIX . "adminMgr`\n                (\n                    `id`        INT UNSIGNED NOT NULL PRIMARY KEY auto_increment,\n                    `admin_u`    VARCHAR(60) UNIQUE,\n                    `admin_e`    VARCHAR(100) UNIQUE,\n                    `admin_p`    VARCHAR(150) DEFAULT NULL,\n                    `admin_v`    VARCHAR(150) NOT NULL,\n                    `is_admin`    TINYINT(1) DEFAULT '0',\n                    INDEX(admin_v)\n                ) ENGINE=MYISAM CHARACTER SET " . DEFAULT_CHARACTER_SET . " COLLATE " . DEFAULT_COLLATION . ";\n                INSERT INTO `" . DB_NAME . "`.`" . DB_PREFIX . "entryMgr`\n                (\n                    `page`, `title`, `body`, `img`, `imgcap`,\n                    `data2`, `data6`, `author`, `created`\n                )\n                VALUES\n                (\n                    '" . DEFAULT_PAGE . "', 'Welcome to the ECMS!',\n                    '<p>You have successfully installed the " . "<a href=\"http://ennuicms.com/\">ECMS</a>.</p>" . "\r\n<p>To get started:</p>\r\n<ul>\r\n<li>" . "<a href=\"/admin\">Log in</a> using the username " . "and password you set up in the config files</li>\r\n" . "<li>Edit this entry to contain the content for your " . "site''s home page</li>\r\n<li>Add content to the " . "rest of the pages on your site</li>\r\n</ul>\r\n" . "<h2>HTML Element Style Test (h2)</h2>\r\n" . "<blockquote>\r\n<p>This is a blockquote. Putamus " . "lectores litterarum dynamicus facilisi dolore. " . "Facilisi qui zzril legunt nibh in. Nostrud nonummy " . "sequitur autem consequat ut. Assum tincidunt " . "vulputate gothica molestie veniam.</p>\r\n" . "</blockquote>\r\n<h3>H3 Element</h3>\r\n<p>Sed " . "consequat tempor ex formas dignissim. Lobortis " . "anteposuerit consectetuer consequat ullamcorper " . "dolore. Dolore imperdiet amet iis sed iriure. " . "Luptatum adipiscing lorem augue diam te. Cum autem " . "claritas tempor sed augue.</p>\r\n<h4>H4 Element" . "</h4>\r\n<ol>\r\n<li>This is an ordered list</li>" . "\r\n<li>Typi at doming usus lectores parum.</li>" . "\r\n<li>Parum quod legentis qui nonummy mirum. Nunc " . "quis consequat in seacula consectetuer.</li>\r\n" . "</ol>\r\n<h5>H5 Element</h5>\r\n<p>Parum quod " . "legentis qui nonummy mirum. Nunc quis consequat in " . "seacula consectetuer. Est humanitatis eros duis qui " . "quarta. Enim quod in aliquip placerat insitam. " . "Putamus consequat hendrerit demonstraverunt " . "eleifend claram. Videntur molestie typi hendrerit " . "duis qui.</p>\r\n<h6>H6 Element</h6>\r\n<p>Mazim ut " . "euismod formas amet in. Ex blandit nulla tincidunt " . "wisi consequat. Typi illum ad luptatum " . "Investigationes legentis.</p>',\n                    'blog, entry, testing', 'welcome-to-the-ecms',\n                    'Ennui Design', " . time() . "\n                )\n                ON DUPLICATE KEY UPDATE `created`=" . time() . ";";
     if (DEV_PASS != '') {
         $sql .= "INSERT INTO `" . DB_NAME . "`.`" . DB_PREFIX . "adminMgr`\n                    (`admin_u`, `admin_e`, `admin_p`, `admin_v`, `is_admin`)\n                VALUES\n                    ('{$admin_u}', '{$admin_e}', '{$admin_p}', '" . sha1(time()) . "', '1')\n                ON DUPLICATE KEY UPDATE `is_admin`=1;";
     }
     if (array_key_exists('blog', $menuPages)) {
         $sql .= "\n                CREATE TABLE IF NOT EXISTS `" . DB_NAME . "`.`" . DB_PREFIX . "blogCmnt`\n                (\n                    `id`        INT(5) PRIMARY KEY auto_increment,\n                    `bid`        INT(5),\n                    `user`        VARCHAR(60),\n                    `email`        VARCHAR(100),\n                    `link`        VARCHAR(100),\n                    `comment`    TEXT,\n                    `timestamp`    INT(12),\n                    `subscribe`    TINYINT(1) DEFAULT '0',\n                    INDEX(bid),\n                    INDEX(timestamp),\n                    INDEX(subscribe)\n                ) ENGINE=MYISAM CHARACTER SET " . DEFAULT_CHARACTER_SET . " COLLATE " . DEFAULT_COLLATION . ";";
     }
     if ($mysqli->multi_query($sql)) {
         do {
             if ($result = $mysqli->store_result()) {
                 echo "Table created.<br />\n";
                 $result->close();
             }
         } while ($mysqli->next_result());
     } else {
         exit('Database tables could not be created. ' . $mysqli->error());
     }
     $mysqli->close();
     return true;
 }
开发者ID:RobMacKay,项目名称:Ennui-CMS,代码行数:29,代码来源:class.adminutilities.inc.php

示例12: while

            city_cat_load('categories');
            break;
        case 'categories':
            userfunc_query('SELECT * FROM `categories`');
            while ($row = $result->fetch_assoc()) {
                $categories[$row['cat_name']][$row['subcat_id']] = $row['subcat_name'];
            }
            $result->free();
            break;
    }
}
//конец функций
$ads_db = new mysqli($_SESSION['server_name'], $_SESSION['user_name'], $_SESSION['password'], $_SESSION['database']);
//устанавливаем соденинение
if ($ads_db->connect_errno > 0) {
    die('Unable to connect' . $ads_db->connect_error());
}
if (!$ads_db->set_charset('utf8')) {
    die('Error while applying utf8 charset' . $ads_db->error);
}
city_cat_load('cities_and_categories');
//подгружаем наши массивы с городами и категориями
$ads_container = "";
$showform_params = array('return_private' => "0", 'namereturn' => "", 'email_return' => "", 'return_send_email' => "1", 'phonereturn' => "", 'city' => "", 'returncategory' => "", 'returntitle' => "", 'returndescription' => "", 'returnprice' => "0", 'notice_field_is_empty' => "");
if (isset($_POST['main_form_submit'])) {
    //блок проверки какая кнопка была нажата. Если Отправить, то передаем записи из поста в сессию
    if ($_POST['title']) {
        if (isset($_SESSION['save_changes_id'])) {
            //при нажатой кнопке Отправить если в сессии сохранен ключ редактируемого обьявления, то сохраняем в него вместо создания нового.
            $statement = $ads_db->prepare('UPDATE `ads_container` SET `private` = ?, `seller_name` = ?, `email` = ?, `allow_mails` = ?, `phone` = ?, `location_id` = ?, `category_id` = ?, `title` = ?, `description` = ?, `price` = ? WHERE `id` = ?');
            $statement->bind_param('ississssssi', $_POST['private'], $_POST['seller_name'], $_POST['email'], allow_mails(), $_POST['phone'], $_POST['location_id'], $_POST['category_id'], $_POST['title'], $_POST['description'], $_POST['price'], $_SESSION['save_changes_id']);
开发者ID:Anatoliy-Bezhenaru,项目名称:xaver.loc,代码行数:31,代码来源:Lesson9HW_MYSQLi.php

示例13: mysqli

<?php

$db_ini = parse_ini_file('../dbconf.ini');
$conn = new mysqli($db_ini['server'], $db_ini['username'], $db_ini['password']);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error());
}
$sql = "CREATE DATABASE ourDB";
if ($conn->query($sql) === TRUE) {
    echo "Database created successfuly";
} else {
    echo "Error creating database: " . $conn->error;
}
$conn->close();
开发者ID:9thScientist,项目名称:bad_webdev,代码行数:14,代码来源:createDB.php


注:本文中的mysqli::connect_error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。