當前位置: 首頁>>代碼示例>>PHP>>正文


PHP mysqli_select_db函數代碼示例

本文整理匯總了PHP中mysqli_select_db函數的典型用法代碼示例。如果您正苦於以下問題:PHP mysqli_select_db函數的具體用法?PHP mysqli_select_db怎麽用?PHP mysqli_select_db使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了mysqli_select_db函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: wechatFlow

 public function wechatFlow()
 {
     $this->conn = new mysqli("localhost", USER, PASSWORD);
     //連接MySql
     if ($this->conn->connect_errno) {
         die("Connect Error(" . $this->conn->connect_errno . ")" . $this->conn->connect_error);
     }
     $this->conn->query("SET NAMES UTF8");
     $this->conn->query("CREATE DATABASE IF NOT EXISTS " . DATABASE . " DEFAULT CHARACTER SET UTF8");
     //創建數據庫
     mysqli_select_db($this->conn, DATABASE);
     //選擇數據庫
     $this->conn->query("CREATE TABLE IF NOT EXISTS rel_manager(\r\n\t\t\tid int not null primary key auto_increment,\r\n\t\t\tmanager_name LONGTEXT CHARACTER SET UTF8,\r\n\t\t\tmanager_password LONGTEXT CHARACTER SET UTF8,\r\n\t\t\tcomment LONGTEXT CHARACTER SET UTF8\r\n\t\t)");
     //創建管理員表
     //		$value=mysql_query("SELECT * FROM rel_manager");
     //		//if(!$row=mysql_fetch_array($value)){//如果超級管理員不存在
     //			$manager_password="123456";
     //			$password=md5($manager_password);
     //			mysql_query(" INSERT INTO rel_manager (manager_name,manager_password,A_Group_ID,comment)
     //						  VALUES ('manager','".$password."','1','超級管理員')");
     //		//}//插入超級管理員
     $this->conn->query("CREATE TABLE IF NOT EXISTS rel_alg (\r\n\t\t\tid int not null primary key auto_increment,\r\n\t\t\talg_name LONGTEXT CHARACTER SET UTF8\r\n\t\t)");
     //創建算法表
     $this->conn->query("CREATE TABLE IF NOT EXISTS rel_process (\r\n\t\t\tid int not null primary key auto_increment\r\n\t\t)");
     //創建生命周期過程表
     $this->conn->query("CREATE TABLE IF NOT EXISTS rel_tech (\r\n\t\t\tid int not null primary key auto_increment\r\n\t\t)");
     //創建技術措施表
 }
開發者ID:doit05,項目名稱:relProject,代碼行數:28,代碼來源:wechatLoop.php

示例2: display_view

function display_view()
{
    $con = mysqli_connect('localhost', 'root', '');
    $db = mysqli_select_db($con, 'stats');
    $query = "SELECT s.Year, t.team_name FROM season s, team t where s.winner_team_id = t.team_id";
    $result = mysqli_query($con, $query);
    if ($result) {
        $row = mysqli_fetch_row($result);
        echo '<table border="1" style= "text-align: center; color: #092f44; margin: 0 auto;" >';
        echo '<tr> <th>Season Year</th>
				  <th>Winner Team</th>
				</tr>';
        while ($row) {
            $col = count($row);
            echo "<tr>";
            for ($c = 0; $c < $col; $c++) {
                echo "<td>" . $row[$c] . "</td>";
            }
            echo "</tr>";
            $row = mysqli_fetch_row($result);
        }
        echo "</table>";
    } else {
        echo "err";
    }
}
開發者ID:vidhanshukla,項目名稱:Sports-Statistics-Application,代碼行數:26,代碼來源:season.php

示例3: connect

 function connect($server, $db, $user, $password, $socketPath, $charset = null, $port = false)
 {
     $connection = false;
     if ($socketPath !== false) {
         ini_set("mysqli.default_socket", $socketPath);
     }
     if ($this->UsePersistentConnection == true) {
         // Only supported on PHP 5.3 (mysqlnd)
         if (version_compare(PHP_VERSION, '5.3') > 0) {
             $this->Server = 'p:' . $this->Server;
         } else {
             eZDebug::writeWarning('mysqli only supports persistent connections when using php 5.3 and higher', 'eZMySQLiDB::connect');
         }
     }
     eZPerfLogger::accumulatorStart('mysqli_connection', 'mysqli_total', 'Database connection');
     $connection = mysqli_connect($server, $user, $password, null, (int) $port, $socketPath);
     $dbErrorText = mysqli_connect_error();
     eZPerfLogger::accumulatorStop('mysqli_connection');
     $maxAttempts = $this->connectRetryCount();
     $waitTime = $this->connectRetryWaitTime();
     $numAttempts = 1;
     while (!$connection && $numAttempts <= $maxAttempts) {
         sleep($waitTime);
         eZPerfLogger::accumulatorStart('mysqli_connection', 'mysqli_total', 'Database connection');
         $connection = mysqli_connect($this->Server, $this->User, $this->Password, null, (int) $this->Port, $this->SocketPath);
         eZPerfLogger::accumulatorStop('mysqli_connection');
         $numAttempts++;
     }
     $this->setError();
     $this->IsConnected = true;
     if (!$connection) {
         eZDebug::writeError("Connection error: Couldn't connect to database. Please try again later or inform the system administrator.\n{$dbErrorText}", __CLASS__);
         $this->IsConnected = false;
         throw new eZDBNoConnectionException($server);
     }
     if ($this->IsConnected && $db != null) {
         eZPerfLogger::accumulatorStart('mysqli_connection', 'mysqli_total', 'Database connection');
         $ret = mysqli_select_db($connection, $db);
         eZPerfLogger::accumulatorStop('mysqli_connection');
         if (!$ret) {
             //$this->setError();
             eZDebug::writeError("Connection error: " . mysqli_errno($connection) . ": " . mysqli_error($connection), "eZMySQLiDB");
             $this->IsConnected = false;
         }
     }
     if ($charset !== null) {
         $originalCharset = $charset;
         $charset = eZCharsetInfo::realCharsetCode($charset);
     }
     if ($this->IsConnected and $charset !== null) {
         eZPerfLogger::accumulatorStart('mysqli_connection', 'mysqli_total', 'Database connection');
         $status = mysqli_set_charset($connection, eZMySQLCharset::mapTo($charset));
         eZPerfLogger::accumulatorStop('mysqli_connection');
         if (!$status) {
             $this->setError();
             eZDebug::writeWarning("Connection warning: " . mysqli_errno($connection) . ": " . mysqli_error($connection), "eZMySQLiDB");
         }
     }
     return $connection;
 }
開發者ID:gggeek,項目名稱:ezperformancelogger,代碼行數:60,代碼來源:ezmysqlitracingdb.php

示例4: connect

 public function connect()
 {
     if ($this->conn_id && $this->state == self::OPEN) {
         mysqli_select_db($this->conn_id, $this->getDatabase());
         return true;
     }
     //TODO preConnect actions should be called from here
     $hostString = $this->getHost();
     if ($this->getPort() != '') {
         $hostString .= ':' . $this->getPort();
     }
     if (isset($this->options['socket']) && $this->options['socket'] != '') {
         $hostString .= ':' . $this->options['socket'];
     }
     $flags = isset($this->options['flags']) ? $this->options['flags'] : null;
     if (isset($this->options['persistent']) && $this->options['persistent'] == true) {
         $this->conn_id = @mysqli_pconnect($hostString, $this->getUser(), $this->getPassword(), $flags);
     } else {
         $this->conn_id = @mysqli_connect($hostString, $this->getUser(), $this->getPassword(), $flags);
     }
     if (!$this->conn_id) {
         $this->state = self::CLOSED;
         $msg = '[!Database connection error!]: ' . $this->getDatabase() . ' - ' . $this->getErrorMsg();
         PhpBURN_Message::output($msg, PhpBURN_Message::ERROR);
         return false;
     }
     //Selecting database
     mysqli_select_db($this->conn_id, $this->getDatabase());
     $this->state = self::OPEN;
     //TODO onConnectSucess actions should be called from here
     return true;
 }
開發者ID:phpburn,項目名稱:phpburn,代碼行數:32,代碼來源:MySQLi.php

示例5: _getDb

 /**
  * 指定 mcString 得到對應的 memcache 對象
  *
  * @param string $mcString
  * @return memcache
  */
 private function _getDb($dbString)
 {
     $dbConfig = new Yaf_Config_Ini(APPLICATION_PATH . '/conf/database.ini', YAF_ENVIRON);
     if (!$dbConfig instanceof Yaf_Config_Ini) {
         exit("db system err");
     }
     if (!$dbConfig->database->get($dbString)) {
         exit("no dbstring: " . $dbString);
     }
     if (!isset(self::$_dbPool[$dbString])) {
         $link = mysqli_connect($dbConfig->database->get($dbString)->host, $dbConfig->database->get($dbString)->username, $dbConfig->database->get($dbString)->password, '', $dbConfig->database->get($dbString)->port);
         if (!$link) {
             logLib::errorModuleLog($dbString);
             return false;
         }
         $this->_db = $link;
         $this->_dbKey = '';
         self::$_dbPool[$dbString] = $link;
     } else {
         $this->_db = self::$_dbPool[$dbString];
     }
     if ($this->_dbKey != $dbString) {
         //         	mysql_select_db($dbconfig['dbname'], $this->_db);
         mysqli_select_db($this->_db, $dbConfig->database->get($dbString)->dbname);
         $this->_dbKey = $dbString;
     }
     return true;
 }
開發者ID:lfq618,項目名稱:yafdemo,代碼行數:34,代碼來源:dbLib.php

示例6: get_data

 public function get_data()
 {
     $con = mysqli_connect("localhost", "MaxMelnyk", "781227maks") or die("Something wrong...");
     mysqli_select_db($con, "tour_firm") or die(mysql_error());
     mysqli_query($con, 'SET NAMES utf8');
     $query = "SELECT * FROM tours WHERE ID = " . $_GET['id'];
     $res = mysqli_query($con, $query) or die(mysql_error());
     $data['tour'] = mysqli_fetch_array($res);
     $query = "SELECT * FROM cities WHERE tourID = " . $data['tour']['ID'] . " ORDER BY starttime";
     $res = mysqli_query($con, $query) or die(mysql_error());
     $num_cities = $res->num_rows;
     foreach ($res as $row) {
         $data['cities'][] = $row;
     }
     for ($i = 0; $i < $num_cities; $i++) {
         $query = "SELECT * FROM excursions WHERE cityID = " . $data['cities'][$i]['ID'] . " ORDER BY starttime";
         $res = mysqli_query($con, $query) or die(mysql_error());
         foreach ($res as $row) {
             $data['cities'][$i]['excursions'][] = $row;
         }
         $query = "SELECT * FROM accommodation WHERE cityID = " . $data['cities'][$i]['ID'];
         $res = mysqli_query($con, $query) or die(mysql_error());
         $data['cities'][$i]['accommodation'] = mysqli_fetch_array($res);
         if ($i != $num_cities - 1) {
             $query = "SELECT * FROM transfers WHERE startcityID = " . $data['cities'][$i]['ID'] . " AND finishcityID = " . $data['cities'][$i + 1]['ID'] . " AND tourID = " . $data['tour']['ID'];
             $res = mysqli_query($con, $query) or die(mysql_error());
             $data['transfers'][] = mysqli_fetch_array($res);
         }
     }
     return $data;
 }
開發者ID:maksym1up,項目名稱:tour_firm,代碼行數:31,代碼來源:model_tour.php

示例7: connect

 function connect($db_type, $var1 = false, $var2 = false, $var3 = false, $var4 = false, $var5 = '')
 {
     global $db_connected, $mysql_connect, $mysql_select_db, $sqlite_open, $db_type1, $db_prefix;
     $db_type1 = $db_type;
     $db_prefix = $var5;
     switch ($db_type) {
         case 'mysql':
             #var1 = db_host | var2 = db_user | var3 = db_pass | var4 = db_name | var5 = db_prefix
             $mysql_connect = mysql_connect($var1, $var2, $var3) or die("ERROR: 001");
             if ($mysql_connect) {
                 mysql_select_db($var4, $mysql_connect) or die("ERROR: 002");
                 mysql_query("SET NAMES 'utf8'");
                 $db_connected = true;
             }
             break;
         case 'mysqli':
             #var1 = db_host | var2 = db_user | var3 = db_pass | var4 = db_name | var5 = db_prefix
             $mysql_connect = mysqli_connect($var1, $var2, $var3, $var4) or die("ERROR: 001");
             if ($mysql_connect) {
                 mysqli_select_db($mysql_connect, $var4) or die("ERROR: 002");
                 mysqli_query($mysql_connect, "SET NAMES 'utf8'");
                 $db_connected = true;
             }
             break;
         case 'sqlite':
             #var1 = db_path
             $sqlite_open = sqlite_open($var1, 0666, $sqlite_error) or die("ERROR: 003");
             sqlite_query($sqlite_open, "SET NAMES 'utf8'");
             if ($sqlite_open) {
                 $db_connected = true;
             }
             break;
     }
 }
開發者ID:sayedgfx,項目名稱:foxycms-1,代碼行數:34,代碼來源:databases.php

示例8: display_view

function display_view()
{
    $con = mysqli_connect('localhost', 'root', '');
    $db = mysqli_select_db($con, 'stats');
    $query = "SELECT team_name,(no_of_wins + no_of_losses+no_of_draws) as Total_Matches, no_of_wins,no_of_losses,no_of_draws FROM team order by Total_Matches desc";
    $result = mysqli_query($con, $query);
    if ($result) {
        $row = mysqli_fetch_row($result);
        echo '<table border="1" style= "text-align: center; color: #092f44; margin: 0 auto;" >';
        echo '<tr> <th>Team </th>
				  <th>Matches Played</th>
                  <th>WON</th>
                  <th>LOST</th>
                  <th>DRAW</th>                  
				</tr>';
        while ($row) {
            $col = count($row);
            echo "<tr>";
            for ($c = 0; $c < $col; $c++) {
                echo "<td>" . $row[$c] . "</td>";
            }
            echo "</tr>";
            $row = mysqli_fetch_row($result);
        }
        echo "</table>";
    } else {
        echo "err";
    }
}
開發者ID:vidhanshukla,項目名稱:Sports-Statistics-Application,代碼行數:29,代碼來源:Teams.php

示例9: connect

 /**
  * Function to connect with database
  */
 function connect()
 {
     // Connecting to mysql database
     $this->connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());
     // Selecing database
     $db = mysqli_select_db($this->connection, DB_DATABASE) or die(mysql_error()) or die(mysql_error());
 }
開發者ID:abhik-setia,項目名稱:MCQTECHNO,代碼行數:10,代碼來源:db_connect.php

示例10: dbConnect

 private function dbConnect()
 {
     $this->obDb = mysqli_connect(self::DB_SERVER, self::DB_USER, self::DB_PASSWORD);
     if ($this->obDb) {
         mysqli_select_db($this->obDb, self::DB);
     }
 }
開發者ID:hardikpatel1644,項目名稱:simple_rest_api,代碼行數:7,代碼來源:api.php

示例11: connect

 function connect($db)
 {
     if ($db['port']) {
         $db['server'] .= ':' . $port;
     }
     if ($this->link_identifier) {
         $this->disconnect();
     }
     $this->link_identifier = $db['persistent'] ? @mysqli_pconnect($db['server'], $db['username'], $db['password']) : @mysqli_connect($db['server'], $db['username'], $db['password']);
     if ($this->link_identifier) {
         if (@mysqli_select_db($this->link_identifier, $db['database'])) {
             mysqli_query($this->link_identifier, 'SET NAMES utf8');
             //mysqli_query($this->link_identifier, 'SET character_set_results = NULL');
             return $this->link_identifier;
         }
         $error = '<center>There is currently a problem with the site<br/>Please try again later<br /><br />Error Code: DB2</center>';
     }
     if (!$this->report_error) {
         return false;
     }
     if (!isset($error)) {
         $error = '<center>There is currently a problem with the site<br/>Please try again later<br /><br />Error Code: DB1</center>';
     }
     $this->disconnect();
     trigger_error($error, E_USER_ERROR);
     die;
 }
開發者ID:BackupTheBerlios,項目名稱:viperals-svn,代碼行數:27,代碼來源:mysqli.php

示例12: createHR

 public function createHR($selectedName)
 {
     //$conn = connect();
     $servername = "localhost";
     $username = "root";
     $password = "sqldba";
     $dbname = "rfid_database";
     $conn = new mysqli($servername, $username, $password, $dbname);
     if ($conn->connect_error) {
         die("Connection failed: " . $conn->connect_error);
     }
     $sql = "SELECT users.userName, nomenclature.nomenclature_Name, locations.roomNumber, makes.makeName, models.model_Name, items.rfid, items.serialNum FROM items join locations on items.location_id=locations.location_id join models on items.model_id=models.model_id join nomenclature on nomenclature.nomenclature_id=models.nom_id join makes on models.make_id=makes.make_id join users on users.user_id=items.user_id WHERE userName like '%{$selectedName}%' ";
     // WHERE user.userName=$selectedName
     $result = $conn->query($sql);
     if (!$result) {
         die("Didn't Work " . mysqli_error($conn));
     }
     mysqli_select_db($conn, "rfid_database");
     // output data of each row
     echo "<table>\r\n\t\t<tr>\r\n\t\t<th>Nomenclature</th>\r\n\t\t<th>Count</th>\r\n\t\t<th>Location</th>\r\n\t\t<th>Make</th>\r\n\t\t<th>Model</th>\r\n\t\t<th>Serial Number</th>\r\n\t\t<th>RFID</th>\t\t\r\n\t\t</tr>";
     while ($row = mysqli_fetch_array($result)) {
         echo "<tr>";
         echo "<td>" . $row['nomenclature_Name'] . "</td>";
         echo "<td> 1 </td>";
         echo "<td>" . $row['roomNumber'] . "</td>";
         echo "<td>" . $row['makeName'] . "</td>";
         echo "<td>" . $row['model_Name'] . "</td>";
         echo "<td>" . $row['serialNum'] . "</td>";
         echo "<td>" . $row['rfid'] . "</td>";
         echo "</tr>";
     }
     echo "</table>";
     mysqli_close($conn);
 }
開發者ID:Notacadet,項目名稱:RFID,代碼行數:34,代碼來源:getHR.php

示例13: init

function init()
{
    $link = connect(false);
    if (mysqli_select_db($link, "synapp_db")) {
        mysqli_close($link);
        unset($link);
        return INST_DB_EXISTS;
    }
    $sql = "CREATE DATABASE synapp_db";
    if (!mysqli_query($link, $sql)) {
        die("mysql CREATE DATABASE error.");
    }
    $sql = "ALTER DATABASE synapp_db CHARACTER SET utf8 COLLATE utf8_unicode_ci";
    if (!mysqli_query($link, $sql)) {
        die("mysql ALTER DATABASE synapp_db CHARACTER SET utf8 COLLATE utf8_unicode_ci error.");
    }
    if (!mysqli_select_db($link, "synapp_db")) {
        die("mysqli_select_db() error.");
    }
    create_all_languages_table($link);
    $sql = "CREATE TABLE IF NOT EXISTS users (user VARCHAR(32) UNIQUE KEY,pass VARCHAR(64),recovery VARCHAR(64)," . "firstdate INT,hfirstdate BIT DEFAULT 0,missed_logins INT DEFAULT 0,last_login INT,hlast_login BIT DEFAULT 0,ip INT UNSIGNED,last_update INT," . "interface_language VARCHAR(4),hinterface_language BIT DEFAULT '0',working_group VARCHAR(32),hworking_group BIT DEFAULT 0,input_language VARCHAR(4),hinput_language BIT DEFAULT 0,hprofile BIT DEFAULT 0," . "gender VARCHAR(1) DEFAULT NULL, hgender BIT DEFAULT 0,birthday DATE, hbirthday BIT DEFAULT 0,studies VARCHAR(256), hstudies BIT DEFAULT 0,studies_type VARCHAR(64), hstudies_type BIT DEFAULT 0,studies_level INT, hstudies_level BIT DEFAULT 0, occupation VARCHAR(256),hoccupation BIT DEFAULT 0," . "email VARCHAR(128),hemail BIT DEFAULT 0,email_confirmation_code VARCHAR(64),confirmed_email BIT DEFAULT 0,avatar VARCHAR(128),hstats BIT DEFAULT 0, ditloid_lock_timestamp INT DEFAULT NULL, ditloid_time_left_when_locked INT DEFAULT 0, gotestbefore INT DEFAULT 0," . "gotestafter INT DEFAULT 0, timer_ctestb_start INT DEFAULT 0, timer_ctestb_end INT DEFAULT 0, timer_utestb_start INT DEFAULT 0, timer_utestb_end INT DEFAULT 0, timer_utesta_start INT DEFAULT 0, timer_utesta_end INT DEFAULT 0, timer_ctesta_start INT DEFAULT 0, timer_ctesta_end INT DEFAULT 0, fbid VARCHAR(255) DEFAULT NULL)";
    if (!mysqli_query($link, $sql)) {
        die('Error: ' . var_export($link->errorInfo(), true));
    }
    $sql = "CREATE TABLE `interface_languages` (native_name VARCHAR(32), iso6392_code VARCHAR(4) UNIQUE KEY, users INT DEFAULT 0)";
    if (mysqli_query($link, $sql)) {
        $sql = "INSERT INTO interface_languages VALUES (\"español\", \"spa\", \"0\")";
        mysqli_query($link, $sql);
        $sql = "INSERT INTO interface_languages VALUES (\"english\", \"eng\", \"0\")";
        mysqli_query($link, $sql);
        $sql = "INSERT INTO interface_languages VALUES (\"galego\", \"glg\", \"0\")";
        mysqli_query($link, $sql);
        $sql = "INSERT INTO interface_languages VALUES (\"polski\", \"pol\", \"0\")";
        mysqli_query($link, $sql);
    }
    $sql = "CREATE TABLE `groups` (name VARCHAR(32), users INT DEFAULT 0)";
    if (mysqli_query($link, $sql)) {
        $sql = "INSERT INTO groups VALUES (\"DEFAULT_GROUP_A\", \"0\")";
        mysqli_query($link, $sql);
        $sql = "INSERT INTO groups VALUES (\"DEFAULT_GROUP_B\", \"0\")";
        mysqli_query($link, $sql);
    }
    $sql = "CREATE TABLE IF NOT EXISTS `images` (id VARCHAR(69) UNIQUE KEY, name VARCHAR(32), associated_group VARCHAR(32), uploader VARCHAR(32), KEY(associated_group))";
    if (!mysqli_query($link, $sql)) {
        die('Error: ' . var_export($link->errorInfo(), true));
    }
    $sql = "CREATE TABLE IF NOT EXISTS `stats` (user VARCHAR(32),lang VARCHAR(4), day DATE,type INT," . "assigned_group VARCHAR(32), upvotes INT DEFAULT 0, downvotes INT DEFAULT 0, neutralvotes INT DEFAULT 0, popupvotes INT DEFAULT 0, popdownvotes INT DEFAULT 0, popneutralvotes INT DEFAULT 0, count INT DEFAULT 0, UNIQUE INDEX `user_lang_day_type_assigned_group` (`user`, `lang`, `day`, `type`, `assigned_group`))";
    if (!mysqli_query($link, $sql)) {
        die('Error: ' . var_export($link->errorInfo(), true));
    }
    $sql = "CREATE TABLE IF NOT EXISTS `test_ranks` (user VARCHAR(32), ttype VARCHAR(32),evals INT,orgfullvotes INT, orghalfvotes INT, orgzerovotes INT, cohfullvotes INT, cohhalfvotes INT, cohzerovotes INT, UNIQUE INDEX uti (user,ttype))";
    if (!mysqli_query($link, $sql)) {
        die('Error: ' . var_export($link->errorInfo(), true));
    }
    $sql = "CREATE TABLE IF NOT EXISTS `confirmed_emails` (user VARCHAR(32),email VARCHAR(128) UNIQUE KEY, KEY(user))";
    if (!mysqli_query($link, $sql)) {
        die('Error: ' . var_export($link->errorInfo(), true));
    }
    return INST_OK;
}
開發者ID:elcodedocle,項目名稱:synapp,代碼行數:60,代碼來源:init.php

示例14: fetchLogs

function fetchLogs()
{
    $url = parse_url(getenv("CLEARDB_DATABASE_URL"));
    $server = $url["host"];
    $username = $url["user"];
    $password = $url["pass"];
    $db = substr($url["path"], 1);
    $newlink = mysqli_connect($server, $username, $password);
    mysqli_select_db($newlink, $db) or die("Cannot connect to database.");
    $user = $_SESSION['user'];
    if (isset($_POST['message'])) {
        return $_POST['message'];
    } else {
        $newLogQry = "SELECT * FROM `players` WHERE username = '{$user}'";
        if (!mysqli_query($newlink, $newLogQry)) {
            echo mysqli_error($link);
        } else {
            $newLogRes = mysqli_query($newlink, $newLogQry);
        }
        $newLogRows = mysqli_fetch_array($newLogRes);
        $newLog = $newLogRows['logs'];
        return $newLog;
    }
    mysqli_close($newlink);
}
開發者ID:navybofus,項目名稱:SlavehackLegacy,代碼行數:25,代碼來源:logs.php

示例15: get_data

 public function get_data()
 {
     $phoneErr = $nameErr = "";
     $valid1 = $valid2 = false;
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $name = Model_jointour::test_data($_POST['name']);
         $phone = Model_jointour::test_data($_POST['phone']);
         if (!preg_match("/^[a-zA-Zа-яА-Я]*\$/", str_replace(" ", "", $name))) {
             $nameErr = "Wrong characters!";
         } else {
             $valid2 = true;
         }
         if (!preg_match('/^\\+?[0-9]{12,12}$/', $phone)) {
             $phoneErr = "Invalid format!";
         } else {
             $valid1 = true;
         }
     }
     if ($valid1 && $valid2) {
         $con = mysqli_connect("localhost", "MaxMelnyk", "781227maks") or die("Something wrong...");
         mysqli_select_db($con, "tour_firm") or die(mysql_error());
         mysqli_query($con, 'SET NAMES utf8');
         $query = "INSERT INTO tourists (tourID, name, phone) values(" . $_GET['id'] . ", '{$name}', '{$phone}')";
         mysqli_query($con, $query) or die(mysql_error());
     }
     return $data = array('nameErr' => $nameErr, 'phoneErr' => $phoneErr);
 }
開發者ID:maksym1up,項目名稱:tour_firm,代碼行數:27,代碼來源:model_jointour.php


注:本文中的mysqli_select_db函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。