本文整理汇总了PHP中mysql_select_db函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_select_db函数的具体用法?PHP mysql_select_db怎么用?PHP mysql_select_db使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_select_db函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Conecta
function Conecta($strBD)
{
$this->Link = mysql_connect('mysql.opalaclubefranca.com.br', $strBD, 'racnela') or die('Erro BD_Conecta: ' . "<br>" . mysql_error($this->Link));
mysql_select_db($strBD, $this->Link) or die('\\nErro Selecionando DB prod: ' . mysql_error($this->Link));
// define("SET CHARACTER SET ascii");
// define("SET COLLATION_CONNECTION='ascii_general_ci'");
}
示例2: alertnoticias_consultar
function alertnoticias_consultar($consulta,$accion)
{
$enlace = mysql_connect('atc-nh-natsdb.nationalnet.com', 'staffcenter','XgwofvLY2ayLf') or die('No pudo conectarse : ' . mysql_error());
mysql_select_db('staffcenter',$enlace) or die('No pudo seleccionarse la BD.');
$sql = $consulta;
$resultado = mysql_query($sql,$enlace) or die('La consulta falló: ' . mysql_error());
while ($row = mysql_fetch_array($resultado)){
switch($accion)
{
case "noticiasdeldia":
$idsnoticias[]=$row['idnoticia'].",".$row['titulo'];
break;
}
}
mysql_free_result($resultado);
switch($accion)
{
case "noticiasdeldia":
return $idsnoticias;
break;
}
}
示例3: __construct
/**
* Construct the OAuthStoreMySQL.
* In the options you have to supply either:
* - server, username, password and database (for a mysql_connect)
* - conn (for the connection to be used)
*
* @param array options
*/
function __construct($options = array())
{
if (isset($options['conn'])) {
$this->conn = $options['conn'];
} else {
if (isset($options['server'])) {
$server = $options['server'];
$username = $options['username'];
if (isset($options['password'])) {
$this->conn = mysql_connect($server, $username, $options['password']);
} else {
$this->conn = mysql_connect($server, $username);
}
} else {
// Try the default mysql connect
$this->conn = mysql_connect();
}
if ($this->conn === false) {
throw new OAuthException2('Could not connect to MySQL database: ' . mysql_error());
}
if (isset($options['database'])) {
if (!mysql_select_db($options['database'], $this->conn)) {
$this->sql_errcheck();
}
}
$this->query('set character set utf8');
}
}
示例4: gd_db_connect
/**
* Connects to a database. After connecting, you should always call disconnect_db() to close it when
* done.
*/
function gd_db_connect()
{
global $g_table_prefix, $g_db_hostname, $g_db_username, $g_db_password, $g_db_name;
$link = mysql_connect($g_db_hostname, $g_db_username, $g_db_password) or die("Couldn't connect to database.");
@mysql_select_db($g_db_name) or die("couldn't find database '{$g_db_name}'.");
return $link;
}
示例5: DBConnection
function DBConnection($aDBInfo)
{
global $aQueries;
// Initialize query array.
$aQueries = array();
// Populate the special queries list.
$this->aSpecialQueries[CONCAT_ATTACHMENT] = "UPDATE attachment SET filedata = concat(filedata, '%s') WHERE id=%u";
$this->aSpecialQueries[CONCAT_AVATAR] = "UPDATE avatar SET datum = concat(datum, '%s') WHERE id=%u";
// Try and connect to the database server.
if ($this->objConnection = @mysql_connect($aDBInfo['address'], $aDBInfo['username'], $aDBInfo['password'])) {
// Try and select our database.
if (@mysql_select_db($aDBInfo['database'])) {
// Destroy the database connection information.
unset($aDBInfo['address']);
unset($aDBInfo['username']);
unset($aDBInfo['password']);
unset($aDBInfo['database']);
// Flag selection success.
$this->objSelect = TRUE;
} else {
// Flag selection failure.
$this->objSelect = FALSE;
}
} else {
// Flag connection failure.
$this->objConnection = FALSE;
}
}
示例6: _Connect
function _Connect()
{
$value = false;
if (!$this->connected) {
if (!$this->server) {
$this->server = 'localhost';
}
$host = $this->server;
if ($this->port) {
$host .= ':' . $this->port;
}
$this->link_id = mysql_connect($host, $this->username, $this->password);
}
if ($this->link_id > 0) {
if (empty($this->database)) {
$value = true;
} elseif ($this->link_id !== -1) {
$value = mysql_select_db($this->database, $this->link_id);
} else {
$value = mysql_select_db($this->database);
}
}
if (!$value) {
$this->error = mysql_error();
}
return $value;
}
示例7: connect
function connect($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = '', $pconnect = 0, $tablepre = '', $time = 0)
{
$this->dbhost = $dbhost;
$this->dbuser = $dbuser;
$this->dbpw = $dbpw;
$this->dbname = $dbname;
$this->dbcharset = $dbcharset;
$this->pconnect = $pconnect;
$this->tablepre = $tablepre;
$this->time = $time;
if ($pconnect) {
if (!($this->link = mysql_pconnect($dbhost, $dbuser, $dbpw))) {
$this->halt('Can not connect to MySQL server');
}
} else {
if (!($this->link = mysql_connect($dbhost, $dbuser, $dbpw))) {
$this->halt('Can not connect to MySQL server');
}
}
if ($this->version() > '4.1') {
if ($dbcharset) {
mysql_query("SET character_set_connection=" . $dbcharset . ", character_set_results=" . $dbcharset . ", character_set_client=binary", $this->link);
}
if ($this->version() > '5.0.1') {
//mysql_query("SET sql_mode=''", $this->link); //关闭严格模式
}
}
if ($dbname) {
mysql_select_db($dbname, $this->link);
}
}
示例8: HackingLog
function HackingLog()
{
echo "You're not allowed to use this program! This attempted violation has been logged and your IP address was captured.";
Warehouse('footer');
if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
if ($openSISNotifyAddress) {
mail($openSISNotifyAddress, 'HACKING ATTEMPT', "INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('{$_SERVER['SERVER_NAME']}','{$ip}','" . date('Y-m-d') . "','{$openSISVersion}','{$_SERVER['PHP_SELF']}','{$_SERVER['DOCUMENT_ROOT']}','{$_SERVER['SCRIPT_NAME']}','{$_REQUEST['modname']}','" . User('USERNAME') . "')");
}
/*if($openSISNotifyAddress)
mail($openSISNotifyAddress,'HACKING ATTEMPT',"INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$_SERVER[REMOTE_ADDR]','".date('Y-m-d')."','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','".User('USERNAME')."')");*/
if (false && function_exists('mysql_query')) {
if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$link = @mysql_connect('os4ed.com', 'openSIS_log', 'openSIS_log');
@mysql_select_db('openSIS_log');
@mysql_query("INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('{$_SERVER['SERVER_NAME']}','{$ip}','" . date('Y-m-d') . "','{$openSISVersion}','{$_SERVER['PHP_SELF']}','{$_SERVER['DOCUMENT_ROOT']}','{$_SERVER['SCRIPT_NAME']}','{$_REQUEST['modname']}','" . User('USERNAME') . "')");
@mysql_close($link);
/*$link = @mysql_connect('os4ed.com','openSIS_log','openSIS_log');
@mysql_select_db('openSIS_log');
@mysql_query("INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$_SERVER[REMOTE_ADDR]','".date('Y-m-d')."','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','".User('USERNAME')."')");
@mysql_close($link);*/
}
}
示例9: connecttodb
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
$link=mysql_connect ("$servername","$dbuser","$dbpassword",TRUE);
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
return $link;
}
示例10: connect
function connect()
{
require_once 'db_config.php';
$con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());
$db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error());
return $con;
}
示例11: Open
function Open($dbType, $connectType = "c", $connect, $username = "", $password = "", $dbName)
{
switch ($dbType) {
case "mssql":
if ($connectType == "c") {
$idCon = mssql_connect($connect, $username, $password);
} else {
$idCon = mssql_pconnect($connect, $username, $password);
}
mssql_select_db($dbName);
break;
case "mysql":
if ($connectType == "c") {
$idCon = @mysql_connect($connect, $username, $password);
} else {
$idCon = @mysql_pconnect($connect, $username, $password);
}
$idCon1 = mysql_select_db($dbName, $idCon);
break;
case "pg":
if ($connectType == "c") {
$idCon = pg_connect($connect . " user=" . $username . " password=" . $password . " dbname=" . $dbName);
} else {
$idCon = pg_pconnect($connect . " user=" . $username . " password=" . $password . " dbname=" . $dbName);
}
break;
default:
$idCon = 0;
break;
}
return $idCon;
}
示例12: connect_db
function connect_db()
{
global $myserv;
$myserv = mysql_connect("localhost", MYSQL_USER, MYSQL_PASSWD);
mysql_select_db(MYSQL_DATABASE);
mysql_set_charset('utf8');
}
示例13: runSQL
function runSQL($query)
{
global $conf;
$link = mysql_connect($conf['db_hostname'], $conf['db_user'], $conf['db_password']);
mysql_select_db($conf['db_name']);
return mysql_query($query);
}
示例14: db_connect
/**
* Connects to database using config, supported types: mysql and mysqli (recommended)
*
* @param $loginInfo array Contains login info instead of params.
* @return mixed returns mysqli class when using mysqli and link resource for mysql.
*/
function db_connect($loginInfo = null)
{
global $sql_type, $sql_host, $sql_user, $sql_pass, $sql_base, $mysqlLink, $mysqli;
// Use $loginInfo?
if (is_array($loginInfo)) {
if (isset($loginInfo['host'])) {
$sql_host = $loginInfo['host'];
}
if (isset($loginInfo['user'])) {
$sql_user = $loginInfo['user'];
}
if (isset($loginInfo['pass'])) {
$sql_user = $loginInfo['pass'];
}
if (isset($loginInfo['db'])) {
$sql_user = $loginInfo['db'];
}
}
switch ($sql_type) {
case "mysql":
$mysqlLink = mysql_connect($sql_host, $sql_user, $sql_pass) or die("Could not connect to MySQL-host. Error is: " . mysql_error());
## This might jump to installer......
mysql_select_db($sql_base, $mysqlLink) or die("Could not select MySQL DB. Error is: " . mysql_error());
return $mysqlLink;
case "mysqli":
$mysqli = new mysqli($sql_host, $sql_user, $sql_pass, $sql_base);
if ($mysqli->connect_error) {
die('Could not connect to MySQL-host. Error is: ' . $mysqli->connect_error);
}
return $mysqli;
default:
die("Something seriously wrong with variable sql_type in function db_connect. The reported sql_type is '{$sql_type}'");
}
// end switch ($sql_type)
}
示例15: connect
/**
* 连接数据库方法
* @access public
* @throws ThinkExecption
*/
public function connect($config='',$linkNum=0,$force=false) {
if ( !isset($this->linkID[$linkNum]) ) {
if(empty($config)) $config = $this->config;
// 处理不带端口号的socket连接情况
$host = $config['hostname'].($config['hostport']?":{$config['hostport']}":'');
// 是否长连接
$pconnect = !empty($config['params']['persist'])? $config['params']['persist']:$this->pconnect;
if($pconnect) {
$this->linkID[$linkNum] = mysql_pconnect( $host, $config['username'], $config['password'],131072);
}else{
$this->linkID[$linkNum] = mysql_connect( $host, $config['username'], $config['password'],true,131072);
}
if ( !$this->linkID[$linkNum] || (!empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) ) {
E(mysql_error());
}
$dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
//使用UTF8存取数据库
mysql_query("SET NAMES '".C('DB_CHARSET')."'", $this->linkID[$linkNum]);
//设置 sql_model
if($dbVersion >'5.0.1'){
mysql_query("SET sql_mode=''",$this->linkID[$linkNum]);
}
// 标记连接成功
$this->connected = true;
// 注销数据库连接配置信息
if(1 != C('DB_DEPLOY_TYPE')) unset($this->config);
}
return $this->linkID[$linkNum];
}