• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mysql_connect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: connect_db

function connect_db()
{
    global $myserv;
    $myserv = mysql_connect("localhost", MYSQL_USER, MYSQL_PASSWD);
    mysql_select_db(MYSQL_DATABASE);
    mysql_set_charset('utf8');
}
开发者ID:elsayhsoft,项目名称:fossil-grader,代码行数:7,代码来源:db.php


示例2: getTangentText

function getTangentText($type, $keyword)
{
    global $dbHost, $dbUser, $dbPassword, $dbName;
    $link = @mysql_connect($dbHost, $dbUser, $dbPassword);
    if (!$link) {
        die("Cannot connect : " . mysql_error());
    }
    if (!@mysql_select_db($dbName, $link)) {
        die("Cannot find database : " . mysql_error());
    }
    $result = mysql_query("SELECT sr_keywords, sr_text FROM soRandom WHERE sr_type = '" . $type . "' ORDER BY sr_ID ASC;", $link);
    $tempCounter = 0;
    while ($row = mysql_fetch_assoc($result)) {
        $pKey = "/" . $keyword . "/";
        $pos = preg_match($pKey, $row['sr_keywords']);
        //echo $pos . " is pos<br>";
        //echo $keyword;
        //echo " is keyword and this is the search return: " . $row['keywords'];
        if ($pos != 0) {
            $text[$tempCounter] = stripslashes($row["sr_text"]);
            $tempCounter++;
        }
    }
    mysql_close($link);
    //$text=htmlentities($text);
    return $text;
}
开发者ID:ui-libraries,项目名称:TIRW,代码行数:27,代码来源:includes.php


示例3: db

 function db($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = 'utf8', $pconnect = 0)
 {
     if ($pconnect) {
         if (!($this->mlink = @mysql_pconnect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL');
         }
     } else {
         if (!($this->mlink = @mysql_connect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL');
         }
     }
     if ($this->version() > '4.1') {
         if ('utf-8' == strtolower($dbcharset)) {
             $dbcharset = 'utf8';
         }
         if ($dbcharset) {
             mysql_query("SET character_set_connection={$dbcharset}, character_set_results={$dbcharset}, character_set_client=binary", $this->mlink);
         }
         if ($this->version() > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->mlink);
         }
     }
     if ($dbname) {
         mysql_select_db($dbname, $this->mlink);
     }
 }
开发者ID:eappl,项目名称:prototype,代码行数:26,代码来源:db.class.php


示例4: Global_Init

function Global_Init()
{
    //session_start();
    Load_Configs();
    if (!strnatcasecmp(trim($GLOBALS['db']['type']), "LB")) {
        require_once 'inc/dbmodule_LB.php';
    }
    if (!strnatcasecmp(trim($GLOBALS['db']['type']), "GD")) {
        require_once 'inc/dbmodule_GD.php';
    }
    //echo "GLOBALS: <BR>"; print_r($GLOBALS['db']); echo "<BR>";
    $source_db_ok = SQL_DB_OK("source");
    if ($source_db_ok['error'] === false) {
        $GLOBALS['db']['s_resource'] = @mysql_connect($GLOBALS['db']['s_host'], $GLOBALS['db']['s_user'], $GLOBALS['db']['s_pass']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to Source MySQL Server. : " . mysql_error());
        @mysql_selectdb($GLOBALS['db']['s_base']) or die("Could not connect to Source database [" . $GLOBALS['db']['s_base'] . "] : " . mysql_error());
        $GLOBALS['db']['x_resource'] = @mysql_connect($GLOBALS['db']['x_host'], $GLOBALS['db']['x_user'], $GLOBALS['db']['x_pass']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to X-Ray  MySQL Server. : " . mysql_error());
        @mysql_selectdb($GLOBALS['db']['x_base']) or die("Could not connect to X-Ray database [" . $GLOBALS['db']['x_base'] . "] : " . mysql_error());
        $GLOBALS['db']['s_link'] = mysqli_connect($GLOBALS['db']['s_host'], $GLOBALS['db']['s_user'], $GLOBALS['db']['s_pass'], $GLOBALS['db']['s_base']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to Source MySQL Server (multilink). : " . mysqli_error($GLOBALS['db']['s_link']));
        mysqli_select_db($GLOBALS['db']['s_link'], $GLOBALS['db']['s_base']) or die("Could not connect to Source database (multilink) [" . $GLOBALS['db']['s_base'] . "] : " . mysqli_error($GLOBALS['db']['s_link']));
        $GLOBALS['db']['x_link'] = mysqli_connect($GLOBALS['db']['x_host'], $GLOBALS['db']['x_user'], $GLOBALS['db']['x_pass'], $GLOBALS['db']['x_base']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to X-Ray MySQL Server (multilink). : " . mysqli_error($GLOBALS['db']['x_link']));
        mysqli_select_db($GLOBALS['db']['x_link'], $GLOBALS['db']['x_base']) or die("Could not connect to X-Ray database (multilink) [" . $GLOBALS['db']['x_base'] . "] : " . mysqli_error($GLOBALS['db']['x_link']));
    } else {
        $config_error .= $source_db_ok['message'] . "<BR>";
    }
    //	array_key_exists('form', $_POST) && $_POST['form']!="" ? $_GET = $_POST : NULL;
    //	array_key_exists('force', $_GET) && $_GET['force']!="" ? $_POST = $_GET : NULL;
    if (count($_GET) > 0) {
        $_POST = $_GET;
    }
    //	if($_POST['form']!=""){$_GET = $_POST;}
    //	if($_GET['force']!=""){$_POST = $_GET;}
    if (!FixOutput_Bool($GLOBALS['config_settings']['settings']['first_setup'], true, false, true)) {
        $GLOBALS['worlds'] = Get_Worlds_Enabled();
    }
}
开发者ID:babbottscott,项目名称:X-Ray-Detective,代码行数:35,代码来源:core_xdetector.php


示例5: validate

 private function validate()
 {
     if (!defined('DB_HOSTNAME')) {
         $this->error['warning'] = 'Host required!';
     }
     if (!defined('DB_USERNAME')) {
         $this->error['warning'] = 'User required!';
     }
     if (!defined('DB_DATABASE')) {
         $this->error['warning'] = 'Database Name required!';
     }
     if (!($connection = @mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD))) {
         $this->error['warning'] = 'Error: Could not connect to the database please make sure the database server, username and password is correct in the config.php file!';
     } else {
         if (!@mysql_select_db(DB_DATABASE, $connection)) {
             $this->error['warning'] = 'Error: Database "' . DB_DATABASE . '" does not exist!';
         }
         mysql_close($connection);
     }
     if (!$this->error) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:nareshrajaram,项目名称:referralcartdev,代码行数:25,代码来源:upgrade.php


示例6: connect

 /**
 +----------------------------------------------------------
 * 连接数据库方法
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         // 处理不带端口号的socket连接情况
         $host = $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
         if ($this->pconnect) {
             $this->linkID[$linkNum] = mysql_pconnect($host, $config['username'], $config['password'], CLIENT_MULTI_RESULTS);
         } else {
             $this->linkID[$linkNum] = mysql_connect($host, $config['username'], $config['password'], true, CLIENT_MULTI_RESULTS);
         }
         if (!$this->linkID[$linkNum] || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) {
             throw_exception(mysql_error());
         }
         $dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         if ($dbVersion >= "4.1") {
             //使用UTF8存取数据库 需要mysql 4.1.0以上支持
             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];
 }
开发者ID:omusico,项目名称:AndyCMS,代码行数:43,代码来源:DbMysql.class.php


示例7: __connect

 /**
  * DB Connect
  * this method is private
  * @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password
  * @return resource
  */
 function __connect($connection)
 {
     // Ignore if no DB information exists
     if (strpos($connection["db_hostname"], ':') === false && $connection["db_port"]) {
         $connection["db_hostname"] .= ':' . $connection["db_port"];
     }
     // Attempt to connect
     $result = @mysql_connect($connection["db_hostname"], $connection["db_userid"], $connection["db_password"]);
     if (!$result) {
         exit('XE cannot connect to DB.');
     }
     if (mysql_error()) {
         $this->setError(mysql_errno(), mysql_error());
         return;
     }
     // Error appears if the version is lower than 4.1
     if (version_compare(mysql_get_server_info($result), '4.1', '<')) {
         $this->setError(-1, 'XE cannot be installed under the version of mysql 4.1. Current mysql version is ' . mysql_get_server_info());
         return;
     }
     // select db
     @mysql_select_db($connection["db_database"], $result);
     if (mysql_error()) {
         $this->setError(mysql_errno(), mysql_error());
         return;
     }
     return $result;
 }
开发者ID:perzona420,项目名称:xe-core,代码行数:34,代码来源:DBMysql.class.php


示例8: db_connect

function db_connect()
{
    // połączenie z mysql
    mysql_connect(DBHOST, DBUSER, DBPASS) or die('<h2>ERROR</h2> MySQL Server is not responding');
    // wybór bazy danych
    mysql_select_db(DBNAME) or die('<h2>ERROR</h2> Cannot connect to specified database');
}
开发者ID:polekopru,项目名称:AplikacjeInternetowe,代码行数:7,代码来源:config.php


示例9: 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'], CLIENT_MULTI_RESULTS);
         } else {
             $this->linkID[$linkNum] = mysql_connect($host, $config['username'], $config['password'], true, CLIENT_MULTI_RESULTS);
         }
         if (!$this->linkID[$linkNum] || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum]) || C('SPARE_DB_DEBUG')) {
             $errStr = mysql_error();
             $errno = mysql_errno();
             if ($errno == 13047 || C('SPARE_DB_DEBUG')) {
                 if (C('SMS_ALERT_ON')) {
                     Sms::send('mysql超额被禁用,请在SAE日志中心查看详情', $errStr, Sms::MYSQL_ERROR);
                 }
                 //[sae]启动备用数据库
                 if (C('SPARE_DB_HOST')) {
                     $this->linkID[$linkNum] = mysql_connect(C('SPARE_DB_HOST') . (C('SPARE_DB_PORT') ? ':' . C('SPARE_DB_PORT') : ''), C('SPARE_DB_USER'), C('SPARE_DB_PWD'), true, CLIENT_MULTI_RESULTS);
                     if (!$this->linkID[$linkNum]) {
                         throw_exception('备用数据库连接失败');
                     }
                     mysql_select_db(C('SPARE_DB_NAME'), $this->linkID[$linkNum]);
                     //标记使用备用数据库状态
                     $this->is_spare = true;
                 } else {
                     throw_exception($errStr);
                 }
             } else {
                 //[sae] 短信预警
                 if (C('SMS_ALERT_ON')) {
                     Sms::send('数据库连接时出错,请在SAE日志中心查看详情', $errStr, Sms::MYSQL_ERROR);
                 }
                 throw_exception($errStr);
             }
         }
         $dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         if ($dbVersion >= '4.1') {
             //使用UTF8存取数据库 需要mysql 4.1.0以上支持
             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];
 }
开发者ID:ysking,项目名称:commlib,代码行数:65,代码来源:DbMysql.class.php


示例10: 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;
}
开发者ID:ravinderphp,项目名称:revitalise,代码行数:7,代码来源:update.php


示例11: check_connection

function check_connection($user, $pass, $host)
{
    if (!($connection = @mysql_connect("{$host}", "{$user}", "{$pass}"))) {
        return false;
    }
    return $connection;
}
开发者ID:vinothtimes,项目名称:phpdoc,代码行数:7,代码来源:main.php


示例12: 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);*/
    }
}
开发者ID:26746647,项目名称:Belize-openSIS,代码行数:30,代码来源:HackingLog.php


示例13: 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;
}
开发者ID:laiello,项目名称:ebpls,代码行数:32,代码来源:multidbconnection.php


示例14: 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;
 }
开发者ID:niesuch,项目名称:cosmetic-ingredients,代码行数:7,代码来源:db_connect.php


示例15: dbConnection

 private function dbConnection()
 {
     // Stabilisce connessione al DB
     $this->connectionResource = @mysql_connect($this->DB_HOST, $this->DB_USER, $this->DB_PASS) or conf::showerror();
     $dbSelect = @mysql_select_db($this->DB_NAME, $this->connectionResource) or conf::showerror();
     mysql_query("set names utf8") or conf::showerror();
 }
开发者ID:seph89,项目名称:AmmProject,代码行数:7,代码来源:db.php


示例16: setUp

 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->authorizeObj = new authorize($this->testSubject['employeeId'], $this->testSubject['isAdmin']);
     $conf = new Conf();
     $this->connection = mysql_connect($conf->dbhost . ":" . $conf->dbport, $conf->dbuser, $conf->dbpass);
     mysql_select_db($conf->dbname);
     $this->_deleteTestData();
     // Insert job titles
     $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " . "VALUES('JOB001', 'Manager', 'Manager job title', 'no comments', null)");
     $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " . "VALUES('JOB002', 'Driver', 'Driver job title', 'no comments', null)");
     $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " . "VALUES('JOB003', 'Director', 'Director job title', 'no comments', null)");
     $this->_runQuery("INSERT INTO `hs_hr_employee`(emp_number, employee_id, emp_lastname, emp_firstname, emp_nick_name, coun_code) " . "VALUES (11, NULL, 'Arnold', 'Subasinghe', 'Arnold', 'AF')");
     $this->_runQuery("INSERT INTO `hs_hr_employee`(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, emp_nick_name) " . "VALUES (12, NULL, 'Mohanjith', 'Sudirikku', 'Hannadige', 'MOHA')");
     // employees with job titles
     // Driver
     $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " . "VALUES(13, '0013', 'Rajasinghe', 'Saman', 'Marlon', 'JOB002', '[email protected]')");
     // Manager
     $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " . "VALUES(14, '0014', 'Jayasinghe', 'Aruna', 'Shantha', 'JOB001', '[email protected]')");
     // Insert director
     $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " . "VALUES(15, '0032', 'Samuel', 'John', 'A', 'JOB003', '[email protected]')");
     mysql_query("INSERT INTO `hs_hr_emp_reportto` VALUES ('012', '011', 1);");
     mysql_query("INSERT INTO hs_hr_customer(customer_id, name, description, deleted) " . "VALUES(1, 'Test customer', 'description', 0)");
     mysql_query("INSERT INTO hs_hr_project(project_id, customer_id, name, description, deleted) " . "VALUES(1, 1, 'Test project 1', 'a test proj 1', 0)");
     mysql_query("INSERT INTO hs_hr_project(project_id, customer_id, name, description, deleted) " . "VALUES(2, 1, 'Test project 2', 'a test proj 2', 0)");
 }
开发者ID:noikiy,项目名称:owaspbwa,代码行数:31,代码来源:authorizeTest.php


示例17: 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);
     }
 }
开发者ID:RoyZeng,项目名称:custom,代码行数:31,代码来源:db_mysql.class.php


示例18: __construct

 private function __construct()
 {
     $this->connection = mysql_connect(DB_HOST, DB_USER, DB_PASS);
     if ($this->connection) {
         mysql_select_db(DB_NAME);
     }
 }
开发者ID:riverspirit,项目名称:Overdose,代码行数:7,代码来源:db.class.php


示例19: 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;
}
开发者ID:rgarcia,项目名称:generatedata,代码行数:11,代码来源:database.php


示例20: sql_db

 function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->password = $sqlpassword;
     $this->server = $sqlserver;
     $this->dbname = $database;
     if ($this->persistency) {
         $this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
     } else {
         $this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
     }
     if ($this->db_connect_id) {
         if ($database != "") {
             $this->dbname = $database;
             $dbselect = @mysql_select_db($this->dbname);
             if (!$dbselect) {
                 @mysql_close($this->db_connect_id);
                 $this->db_connect_id = $dbselect;
             }
         }
         return $this->db_connect_id;
     } else {
         return false;
     }
 }
开发者ID:ZerGabriel,项目名称:adr-rpg,代码行数:26,代码来源:mysql.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mysql_connect_error函数代码示例发布时间:2022-05-15
下一篇:
PHP mysql_close函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap