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


PHP mysqli_connect_errno函数代码示例

本文整理汇总了PHP中mysqli_connect_errno函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_connect_errno函数的具体用法?PHP mysqli_connect_errno怎么用?PHP mysqli_connect_errno使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: 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;
}
开发者ID:laxsrbija,项目名称:Cinevision,代码行数:33,代码来源:mysql.php

示例2: writeLog

function writeLog($Redirected_URL)
{
    //	Add logging to MySQL database
    $mySQL_username = "";
    $mySQL_password = "";
    $mySQL_database = "";
    //	Connect to database
    $mysqli = new mysqli('localhost', $mySQL_username, $mySQL_password, $mySQL_database);
    /* check connection */
    if (!mysqli_connect_errno()) {
        /* create a prepared statement */
        if ($stmt = $mysqli->prepare("INSERT INTO `stats`\t(`Datetime`,\t`UA`,\t`IP`,\t`Languages`,\t`Domain`,\t`Path`,\t`Destination`) \n\t\t\t\t\t\t\t\t\tVALUES \t(?,\t\t\t\t?,\t\t?,\t\t?,\t\t\t\t \t?,\t\t\t\t?,\t\t\t?)")) {
            $stmt->bind_param('sssssss', $datetime, $ua, $ip, $languages, $domain, $path, $destination);
            $datetime = date("Y-m-d H:i:s");
            $ua = $_SERVER['HTTP_USER_AGENT'];
            $ip = $_SERVER["REMOTE_ADDR"];
            $languages = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
            $domain = $_SERVER['SERVER_NAME'];
            $path = stripslashes($_GET['title']);
            $destination = $Redirected_URL;
            /* execute prepared statement */
            $stmt->execute();
            /* close statement and connection */
            $stmt->close();
            // Write a log file entry for each visitor
            $myFile = "log.txt";
            $fh = fopen($myFile, 'a+');
            // Tab separated. Date/Time	User Agent	IP Address	Language	Server requested	Page requested
            $stringData = $datetime . "\t" . $ua . "\t" . $ip . "\t" . $languages . "\t" . $domain . "\t" . $path . "\t" . $destination . "\n";
            fwrite($fh, $stringData);
            fclose($fh);
        }
    }
}
开发者ID:googlecode-mirror,项目名称:qrwp,代码行数:34,代码来源:config.php

示例3: dbconnect

 public function dbconnect()
 {
     mysqli_connect($this->dbhost, $this->dbuser, $this->dbpass, $this->dbdata);
     if (mysqli_connect_errno()) {
         return "Failed to connect to MySQL: " . mysqli_connect_error();
     }
 }
开发者ID:stevanusc6,项目名称:kontan_datavis,代码行数:7,代码来源:classDatabase.php

示例4: connect

 /**
 +----------------------------------------------------------
 * 连接数据库方法
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         $this->linkID[$linkNum] = new mysqli($config['hostname'], $config['username'], $config['password'], $config['database'], $config['hostport']);
         if (mysqli_connect_errno()) {
             throw_exception(mysqli_connect_error());
         }
         $dbVersion = $this->linkID[$linkNum]->server_version;
         if ($dbVersion >= "4.1") {
             // 设置数据库编码 需要mysql 4.1.0以上支持
             $this->linkID[$linkNum]->query("SET NAMES '" . C('DB_CHARSET') . "'");
         }
         //设置 sql_model
         if ($dbVersion > '5.0.1') {
             $this->linkID[$linkNum]->query("SET sql_mode=''");
         }
         // 标记连接成功
         $this->connected = true;
         //注销数据库安全信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
开发者ID:dalinhuang,项目名称:concourse,代码行数:37,代码来源:DbMysqli.class.php

示例5: Populate

function Populate()
{
    //mysql connection
    $con = mysqli_connect("eu-cdbr-azure-west-a.cloudapp.net", "b8592f1b44ff9a", "fecb2128", "TeamProject");
    if (mysqli_connect_errno()) {
        $result = "f";
    } else {
        //query
        $query = "SELECT Name,Email FROM Subscriber";
        $result = mysqli_query($con, $query);
        //initialize arrays
        $i = 0;
        $subnames = array();
        $submails = array();
        //loop through the database populating
        while ($sub = mysqli_fetch_assoc($result)) {
            $subnames[$i] = $sub['Name'];
            $submails[$i] = $sub['Email'];
            $i++;
        }
        //close conection and return
        mysqli_close($con);
        return array($subnames, $submails);
    }
}
开发者ID:alexandroskou,项目名称:Repository1,代码行数:25,代码来源:Notify.php

示例6: updateDatabase

function updateDatabase($tableName, $columnName, $newInput)
{
    $dbHost = "localhost";
    // Host name
    $dbUsername = "root";
    // Mysql username
    $dbPassword = "VMware5";
    // Mysql password
    $dbName = "manager";
    // Database name
    // $tbl_name="customers"; // Table name
    // Connect to server and select databse.
    $dbCon = new mysqli("{$dbHost}", "{$dbUsername}", "{$dbPassword}", "{$dbName}");
    if (mysqli_connect_errno($dbCon)) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    $columnName = mysqli_real_escape_string($columnName);
    $newInput = mysqli_real_escape_string($newInput);
    $query = "SELECT * FROM {$tableName} WHERE {$columnName} like '%" . "{$newInput}" . "%'";
    // UPDATE {$taableName} set {$columnName} = '{$newpassword}' WHERE cust_num = '{$customerNumber}'";
    // DEBUG
    // echo $query . "<br>";
    $result = $dbCon->query($query);
    return $result;
}
开发者ID:beaverb1ll,项目名称:phpPlayground,代码行数:25,代码来源:searchFunction.php

示例7: connect

 /**
  * 连接数据库方法
  * @access public
  * @throws ThinkExecption
  */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         $this->linkID[$linkNum] = new \mysqli($config['hostname'], $config['username'], $config['password'], $config['database'], $config['hostport'] ? intval($config['hostport']) : 3306);
         if (mysqli_connect_errno()) {
             E(mysqli_connect_error());
         }
         $dbVersion = $this->linkID[$linkNum]->server_version;
         // 设置数据库编码
         $this->linkID[$linkNum]->query("SET NAMES '" . $config['charset'] . "'");
         //设置 sql_model
         if ($dbVersion > '5.0.1') {
             $this->linkID[$linkNum]->query("SET sql_mode=''");
         }
         // 标记连接成功
         $this->connected = true;
         //注销数据库安全信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
开发者ID:hongchonglhm,项目名称:APICloud-ThinkPHP-SDK,代码行数:31,代码来源:Mysqli.class.php

示例8: initDBConnection

 function initDBConnection($test)
 {
     if (!$this->db) {
         if ($test) {
             echo "\nTrying DB Connection to " . $this->dbcData['DB_HOST'] . "...";
         }
         $this->db = new mysqli($this->dbcData['DB_HOST'], $this->dbcData['DB_USER'], $this->dbcData['DB_PASS'], $this->dbcData['DB_NAME']);
         /* verificar conexión */
         if (mysqli_connect_errno()) {
             printf("Connect failed: %s\n", mysqli_connect_error());
             exit;
         }
         //To query with ñ and tildes
         /* cambiar el conjunto de caracteres a utf8 */
         if (!$this->db->set_charset("utf8")) {
             printf("Error cargando el conjunto de caracteres utf8: %s\n", $this->db->error);
             exit;
         } else {
             //printf("Conjunto de caracteres actual: %s\n", $this->db->character_set_name());
         }
         if ($test) {
             echo "\nConnected!!";
         }
     }
 }
开发者ID:jescacena,项目名称:cispAPI,代码行数:25,代码来源:class.DaoFactory.inc.php

示例9: __construct

 private function __construct($connect)
 {
     if (empty($connect)) {
         if ($GLOBALS["i"]["dev"]) {
             $host = "localhost";
             $user = "root";
             $pass = "funkytown";
             $db = "bijoux";
         } else {
             $host = "localhost";
             $user = "nickand5_admin";
             $pass = "v0h1t099";
             $db = "nickand5_bijoux";
         }
     } else {
         $host = $connect["host"];
         $user = $connect["user"];
         $pass = $connect["pass"];
         $db = $connect["db"];
     }
     //Connect to db
     $this->db = mysqli_connect($host, $user, $pass, $db);
     if (mysqli_connect_error()) {
         die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
     }
 }
开发者ID:nac80,项目名称:bijoux-website,代码行数:26,代码来源:NDB.php

示例10: __construct

 public function __construct()
 {
     $this->con = mysqli_connect("localhost", "root", "123456", "passgen");
     if (mysqli_connect_errno()) {
         die("Failed to connect to MySQL: " . mysqli_connect_error());
     }
 }
开发者ID:hemnathmouli,项目名称:Password-Generate-and-save-into-SQL,代码行数:7,代码来源:functions.php

示例11: open_db_connection

 public function open_db_connection()
 {
     $this->connection = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     if (mysqli_connect_errno()) {
         die("connection to database failed: " . mysqli_error());
     }
 }
开发者ID:Frosty92,项目名称:PhotoGallery,代码行数:7,代码来源:database.php

示例12: __construct

 public function __construct($host, $user, $pwd, $dbname)
 {
     $this->db = new mysqli($host, $user, $pwd, $dbname);
     if (mysqli_connect_errno()) {
         throw new Exception("Can't connect to mysql..." . mysqli_connect_errno() . ': ' . mysqli_error());
     }
 }
开发者ID:jankovacs,项目名称:php-legs,代码行数:7,代码来源:MySQLiClass.php

示例13: UpdatePWD

function UpdatePWD($id, $new_pwd)
{
    global $MYSQL_DB_NAME;
    global $MYSQL_USER_ID;
    global $MYSQL_USER_PWD;
    global $LOGON_SESSION_TTL;
    $mysqli = new mysqli("localhost", $MYSQL_USER_ID, $MYSQL_USER_PWD, $MYSQL_DB_NAME);
    /* check connection */
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit;
    }
    $mysqli->query('SET NAMES utf8');
    $stmt = $mysqli->prepare("UPDATE `student_roster` SET `pwd`=?, `pwd_update_time`=? WHERE `id`=? ;");
    if (!$stmt) {
        echo "<h1>prepare statement failed !<h1>";
        return false;
    }
    $stmt->bind_param("sis", $new_pwd, time(), $id);
    if ($stmt->execute() == FALSE) {
        echo "<h1>update password failed !<h1>";
        $stmt->close();
        return false;
    }
    //	echo ("<h1>affected ". $stmt->affected_rows." rows !<h1>");
    $stmt->close();
    return true;
}
开发者ID:senselab,项目名称:CodeSensor,代码行数:28,代码来源:change_pwd.php

示例14: get_fork_data

function get_fork_data($job)
{
    global $mysqli;
    $fork_encrypt_key = md5('huls0fjhslsshskslgjbtqcwijnbxhl2391');
    $fork_raw_data = $job->workload();
    $fork_metadata = json_decode(AESDecryptCtr(base64_decode($fork_raw_data), $fork_encrypt_key, 256), true);
    $fork_key = $fork_metadata['fork_key'];
    $token = $fork_metadata['token'];
    $inikoo_account_code = $fork_metadata['code'];
    if (!ctype_alnum($inikoo_account_code)) {
        print "cant fint account code\n";
        return false;
    }
    include "gearman/conf/dns.{$inikoo_account_code}.php";
    $mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit;
    }
    $mysqli->query("SET NAMES 'utf8'");
    date_default_timezone_set('GMT');
    $mysqli->query("SET time_zone='+0:00'");
    $sql = sprintf("select `Fork Process Data` from `Fork Dimension` where `Fork Key`=%d and `Fork Token`=%s", $fork_key, prepare_mysql($token));
    $res = $mysqli->query($sql);
    if ($row = $res->fetch_assoc()) {
        $fork_data = json_decode($row['Fork Process Data'], true);
        return array('fork_key' => $fork_key, 'inikoo_account_code' => $inikoo_account_code, 'fork_data' => $fork_data);
    } else {
        print "fork data not found";
        return false;
    }
}
开发者ID:inikoo,项目名称:fact,代码行数:32,代码来源:worker.php

示例15: _connect

 /**
  * Creates a real connection to the database with multi-query capability.
  *
  * @return void
  * @throws Zend_Db_Adapter_Mysqli_Exception
  */
 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     if (!extension_loaded('mysqli')) {
         throw new Zend_Db_Adapter_Exception('mysqli extension is not installed');
     }
     // Suppress connection warnings here.
     // Throw an exception instead.
     @($conn = new mysqli());
     if (false === $conn || mysqli_connect_errno()) {
         throw new Zend_Db_Adapter_Mysqli_Exception(mysqli_connect_errno());
     }
     $conn->init();
     $conn->options(MYSQLI_OPT_LOCAL_INFILE, true);
     #$conn->options(MYSQLI_CLIENT_MULTI_QUERIES, true);
     $port = !empty($this->_config['port']) ? $this->_config['port'] : null;
     $socket = !empty($this->_config['unix_socket']) ? $this->_config['unix_socket'] : null;
     // socket specified in host config
     if (strpos($this->_config['host'], '/') !== false) {
         $socket = $this->_config['host'];
         $this->_config['host'] = null;
     } elseif (strpos($this->_config['host'], ':') !== false) {
         list($this->_config['host'], $port) = explode(':', $this->_config['host']);
     }
     #echo "<pre>".print_r($this->_config,1)."</pre>"; die;
     @$conn->real_connect($this->_config['host'], $this->_config['username'], $this->_config['password'], $this->_config['dbname'], $port, $socket);
     if (mysqli_connect_errno()) {
         throw new Zend_Db_Adapter_Mysqli_Exception(mysqli_connect_error());
     }
     $this->_connection = $conn;
     /** @link http://bugs.mysql.com/bug.php?id=18551 */
     $this->_connection->query("SET SQL_MODE=''");
 }
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:41,代码来源:Mysqli.php


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