コード例 #1
0
ファイル: Install.php プロジェクト: noikiy/PD
 public static function installWithoutDemo(JO_Db_Adapter_Abstract $db)
 {
     mysql_connect($db->getConfig('host'), $db->getConfig('username'), $db->getConfig('password'));
     mysql_select_db($db->getConfig('dbname'));
     mysql_set_charset('utf8');
     $structure = APPLICATION_PATH . '/modules/install/structure.sql';
     if (!file_exists($structure)) {
         return false;
     }
     $queryes = self::getQueryes(file($structure));
     $results = array();
     foreach ($queryes as $query) {
         if (trim($query)) {
             try {
                 /*$results[] = */
                 (bool) mysql_query($query);
             } catch (JO_Exception $e) {
                 /*$results[] = false;*/
             }
         }
     }
     $request = JO_Request::getInstance();
     $results[] = $db->insert('users', array('user_id' => 1, 'username' => $request->getPost('username'), 'password' => md5(md5($request->getPost('password'))), 'register_datetime' => new JO_Db_Expr('NOW()'), 'status' => 'activate', 'groups' => 'a:1:{i:2;s:2:"on";}'));
     /*$results[] = */
     $db->update('system', array('value' => $request->getPost('admin_mail')), array('`key` = ?' => 'admin_mail'));
     /*$results[] = */
     $db->update('system', array('value' => $request->getPost('report_mail')), array('`key` = ?' => 'report_mail'));
     if (!in_array(false, $results)) {
         $db_set = "\r\r\n\tdb.adapter = \"MYSQLi\"\r\r\n\tdb.params.host = \"" . $db->getConfig('host') . "\"\r\r\n\tdb.params.username = \"" . $db->getConfig('username') . "\"\r\r\n\tdb.params.password = \"" . $db->getConfig('password') . "\"\r\r\n\tdb.params.dbname = \"" . $db->getConfig('dbname') . "\"\r\r\n\tdb.params.charset =\"utf8\"";
         $results[] = (bool) @file_put_contents(APPLICATION_PATH . '/config/config_db.ini', $db_set);
     }
     return !in_array(false, $results);
 }
コード例 #2
0
 protected function connect()
 {
     if (!function_exists('mysql_connect')) {
         // We have to '@' the actual call since it can spew all sorts of silly
         // noise, but it will also silence fatals caused by not having MySQL
         // installed, which has bitten me on three separate occasions. Make sure
         // such failures are explicit and loud.
         throw new Exception("About to call mysql_connect(), but the PHP MySQL extension is not " . "available!");
     }
     $user = $this->getConfiguration('user');
     $host = $this->getConfiguration('host');
     $database = $this->getConfiguration('database');
     $pass = $this->getConfiguration('pass');
     if ($pass instanceof PhutilOpaqueEnvelope) {
         $pass = $pass->openEnvelope();
     }
     $conn = @mysql_connect($host, $user, $pass, $new_link = true, $flags = 0);
     if (!$conn) {
         $errno = mysql_errno();
         $error = mysql_error();
         throw new AphrontQueryConnectionException("Attempt to connect to {$user}@{$host} failed with error " . "#{$errno}: {$error}.", $errno);
     }
     if ($database !== null) {
         $ret = @mysql_select_db($database, $conn);
         if (!$ret) {
             $this->throwQueryException($conn);
         }
     }
     mysql_set_charset('utf8', $conn);
     return $conn;
 }
コード例 #3
0
function db_connect($host, $username, $password)
{
    if ($r = mysql_connect($host, $username, $password)) {
        mysql_set_charset('cp1251', $r);
    }
    return $r;
}
コード例 #4
0
 function OpenConnection()
 {
     global $mysqlAuthentication;
     global $sqlserverAuthentication;
     $host = null;
     $options = null;
     if (isset($mysqlAuthentication)) {
         $host = $mysqlAuthentication["host"];
         $options = $mysqlAuthentication;
     }
     if ($this->databaseType == 'mySql' || $this->databaseType == 'both') {
         $this->mysqlConnection = @mysql_connect($host, $options["username"], $options["password"]);
     }
     if (isset($this->mysqlConnection)) {
         @mysql_set_charset("utf8");
         @mysql_select_db($options["database"], $this->mysqlConnection);
     }
     if (isset($sqlserverAuthentication)) {
         $host = $sqlserverAuthentication["host"];
         $options = array("Database" => $sqlserverAuthentication["database"], "CharacterSet" => "UTF-8", "UID" => $sqlserverAuthentication["username"], "PWD" => $sqlserverAuthentication["password"]);
     }
     if ($this->databaseType == 'sqlServer' || $this->databaseType == 'both') {
         $this->sqlserverConnection = sqlsrv_connect($host, $options);
     }
 }
コード例 #5
0
 public function save3()
 {
     //获取数据库主机
     $host = $_POST['host'];
     //获取用户帐号
     $user = $_POST['user'];
     //获取用户密码
     $pass = $_POST['pass'];
     //获取数据库名
     $name = $_POST['name'];
     //获取字段前缀
     $prefix = $_POST['prefix'];
     $str = "<?php" . "\r\n";
     $str .= "    define('Sql_type', 'mysql');    //数据库类型" . "\r\n\r\n";
     $str .= "    define('Sql_host', '{$host}');    //服务器地址" . "\r\n\r\n";
     $str .= "    define('Sql_name', '{$name}'); //数据库名  " . "\r\n\r\n";
     $str .= "    define('Sql_user', '{$user}'); //用户名" . "\r\n\r\n";
     $str .= "    define('Sql_pwd', '{$pass}');   //密码" . "\r\n\r\n";
     $str .= "    define('Sql_port', '3306'); //端口" . "\r\n\r\n";
     $str .= "    define('Sql_prefix', '{$prefix}');    //数据库表前缀" . "\r\n\r\n";
     $str .= "    define('Sql_charset', 'utf8');  //数据库编码默认采用utf8";
     file_put_contents(APP_PATH . 'Lib/tm_db.php', $str);
     $lnk = @mysql_connect($host, $user, $pass);
     mysql_set_charset('utf8');
     mysql_query("CREATE DATABASE {$name}");
     mysql_query("USE {$name}");
     $arr = file_get_contents(APP_PATH . '/Lib/tongmeng.sql');
     $res = explode(';', $arr);
     foreach ($res as $Res) {
         $Sql = $Res . ';';
         mysql_query($Sql);
     }
     $this->display('temp_4');
 }
コード例 #6
0
ファイル: QMysql.package.php プロジェクト: Dim4n/Q
 function connect()
 {
     $this->_action = 'connect';
     if (false === ($this->_link = @mysql_connect($this->_config['host'], $this->_config['user'], $this->_config['pass']))) {
         $this->_throwException();
     }
     $this->_action = 'select database';
     if (false === @mysql_select_db($this->_config['path'], $this->_link)) {
         $this->_throwException();
     }
     if (isset($this->_config['params']['charset'])) {
         $this->_action = 'set charset';
         $success = false;
         if (function_exists('mysql_set_charset')) {
             // MySQL 5.0.7 and PHP 5.2.3
             $success = @mysql_set_charset($this->_config['params']['charset'], $this->_link);
         } else {
             $success = @mysql_query('SET NAMES "' . $this->_config['params']['charset'] . '"', $this->_link);
         }
         if (!$success) {
             $this->_throwException();
         }
     }
     return $this;
 }
コード例 #7
0
ファイル: mysql.func.php プロジェクト: hardihuang/zihuaxiang
/**
 * 连接数据库
 * @return resource
 */
function connect()
{
    $link = mysql_connect(DB_HOST, DB_USER, DB_PWD) or die("数据库连接失败Error:" . mysql_errno() . ":" . mysql_error());
    mysql_set_charset(DB_CHARSET);
    mysql_select_db(DB_DBNAME) or die("指定数据库打开失败");
    return $link;
}
コード例 #8
0
function mcm_open_db()
{
    global $mcm;
    mysql_connect($mcm['db_server'], $mcm['db_username'], $mcm['db_password']) or die("Unable to connect to database server.\n");
    mysql_select_db($mcm['db_database']) or die("Unable to open database.\n");
    mysql_set_charset('utf8');
}
コード例 #9
0
 public function connect($host = '', $user = '', $pass = '', $dbname = '', $port = '3066')
 {
     $this->dbname = $dbname;
     if (!$this->con) {
         $myconn = @mysql_connect($host . ':' . $port, $user, $pass);
         // mysql_connect() with variables defined at the start of Database class
         if ($myconn) {
             mysql_set_charset('utf8', $myconn);
             $this->mysql_link = $myconn;
             $seldb = @mysql_select_db($this->dbname, $myconn);
             // Credentials have been pass through mysql_connect() now select the database
             if ($seldb) {
                 $this->con = true;
                 return true;
                 // Connection has been made return TRUE
             } else {
                 array_push($this->result, mysql_error($this->mysql_link));
                 return false;
                 // Problem selecting database return FALSE
             }
         } else {
             array_push($this->result, 'Something unexpected has gone wrong');
             return false;
             // Problem connecting return FALSE
         }
     } else {
         return true;
         // Connection has already been made return TRUE
     }
 }
コード例 #10
0
ファイル: mysql.func.php プロジェクト: yangchenglong/myshop
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 16-1-19
 * Time: 下午9:54
 */
function connect()
{
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('数据库连接失败!');
    mysql_set_charset(DB_CHARSET);
    mysql_select_db(DB_DBNAME) or die('指定数据库打开失败');
    return $link;
}
コード例 #11
0
ファイル: dblib.php プロジェクト: MirellJ/backstage2
function db_connect($dbhost, $dbname, $dbuser, $dbpass)
{
    global $DB_DIE_ON_FAIL, $DB_DEBUG, $CFG;
    if (!($dbh = mysql_connect($dbhost, $dbuser, $dbpass))) {
        if ($DB_DEBUG) {
            echo "<h2>Can't connect to {$dbhost} as {$dbuser}</h2>";
            echo "<p><b>MySQL Error</b>: ", mysql_error();
        } else {
            echo "<h2>Database error encountered</h2>";
        }
        if ($DB_DIE_ON_FAIL) {
            echo "<p>This script cannot continue, terminating.";
            echo "<a href=\"./\">Click here</a> to return to the homepage.";
            die;
        }
    }
    if (!$CFG->dont_select_db) {
        if (!mysql_select_db($dbname)) {
            if ($DB_DEBUG) {
                echo "<h2>Can't select database {$dbname}</h2>";
                echo "<p><b>MySQL Error</b>: ", mysql_error();
            } else {
                echo "<h2>Database error encountered</h2>";
                db_error_mail("{$_SERVER['HTTP_HOST']} DB Select Failed", "Page: {$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
            }
            if ($DB_DIE_ON_FAIL) {
                echo "<p>This script cannot continue, terminating.";
                echo "<a href=\"./\">Click here</a> to return to the homepage.";
                die;
            }
        }
    }
    mysql_set_charset('utf8');
    return $dbh;
}
コード例 #12
0
function conectar()
{
    $li = mysql_connect("localhost", "artes_cotizacion", "Cotizaciones_1209");
    mysql_set_charset('utf8');
    mysql_select_db("artes01_Cotizaciones", $li) or die("Conexión no hecha");
    return $li;
}
コード例 #13
0
ファイル: lib_BD.php プロジェクト: D3Cnet/cuisine
 /**
  * Etablit la connexion à la base de données
  * @param array $aErreurs Le tableau contenant les messages d'erreurs rencontrées
  */
 function connecter(&$aErreurs)
 {
     // Connexion
     $this->link = @mysql_connect($this->host, $this->login, $this->password);
     mysql_select_db($this->database);
     mysql_set_charset('utf8', $this->link);
     mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
     // En cas d'erreur
     if (!$this->link) {
         ajouterErreurDansTableau("Impossible de se connecter à la base de données !", $aErreurs);
         if (MODE_DEBUG) {
             ajouterErreurDansTableau(' -> ' . mysql_error(), $aErreurs);
         }
         return false;
     }
     // Sélection de la base de données
     if (!@mysql_select_db($this->database, $this->link)) {
         ajouterErreurDansTableau("Impossible de sélectionner la base '" . BD_BASE . "' !", $aErreurs);
         if (MODE_DEBUG) {
             ajouterErreurDansTableau(' -> ' . mysql_error(), $aErreurs);
         }
         return false;
     }
     return true;
 }
コード例 #14
0
ファイル: db.php プロジェクト: bottookku/botto
function db_conn()
{
    require __DIR__ . "/../config/config.php";
    $connect = mysql_connect($host, $user, $pass) or die("Ошибка соединения: " . mysql_error());
    mysql_set_charset('utf8', $connect);
    mysql_select_db($db_name);
}
コード例 #15
0
ファイル: mysql.func.php プロジェクト: win87/homarget2
/**
 * Connect to database
 * @return resource
 */
function connect()
{
    $link = mysql_connect(HOST, USER, PWD) or die("Error:" . mysql_errno() . ":" . mysql_error());
    mysql_set_charset(DB_CHARSET);
    mysql_select_db(DATABASE) or die("Connect MySQL failed!");
    return $link;
}
コード例 #16
0
ファイル: db_connect.php プロジェクト: carriercomm/shell-2
function db_connect($db_host, $db_name, $db_user, $db_pass)
{
    $conn = mysql_connect($db_host, $db_user, $db_pass) or die("MySQL-servern är okontaktbar.");
    $databas = mysql_select_db($db_name) or die("Databasen {$db_name} fungerar inte.");
    mysql_set_charset('utf8', $conn);
    return $conn;
}
コード例 #17
0
 function connect($zf_host, $zf_user, $zf_password, $zf_database, $zf_pconnect = 'false', $zp_real = false)
 {
     //@TODO error class required to virtualise & centralise all error reporting/logging/debugging
     $this->database = $zf_database;
     if ($zf_pconnect != 'false') {
         $this->link = @mysql_connect($zf_host, $zf_user, $zf_password, true);
     } else {
         // pconnect disabled ... leaving it as "connect" here instead of "pconnect"
         $this->link = @mysql_connect($zf_host, $zf_user, $zf_password, true);
     }
     if ($this->link) {
         //Check MySQL version and set character_set
         $mysql_version = function_exists('mysql_get_server_info') ? @mysql_get_server_info() : '';
         if ($mysql_version >= '4.1') {
             $character_set_name = 'ujis';
             if (function_exists('mysql_set_charset')) {
                 @mysql_set_charset($character_set_name);
             } else {
                 @mysql_query("set names '" . $character_set_name . "';");
             }
         }
         if (@mysql_select_db($zf_database, $this->link)) {
             $this->db_connected = true;
             return true;
         } else {
             $this->set_error(mysql_errno(), mysql_error(), $zp_real);
             return false;
         }
     } else {
         $this->set_error(mysql_errno(), mysql_error(), $zp_real);
         return false;
     }
 }
コード例 #18
0
ファイル: mysql.php プロジェクト: kveldscholten/Ilch-1.1
function db_connect()
{
    if (defined('CONN')) {
        return;
    }
    define('CONN', @mysql_pconnect(DBHOST, DBUSER, DBPASS));
    $db = @mysql_select_db(DBDATE, CONN);
    if (!CONN) {
        die('Verbindung nicht m&ouml;glich, bitte pr&uuml;fen Sie ihre mySQL Daten wie Passwort, Username und Host<br />');
    }
    if (!$db) {
        die('Kann Datenbank "' . DBDATE . '" nicht benutzen : ' . mysql_error(CONN));
    }
    if (function_exists('mysql_set_charset') and version_compare(mysql_get_server_info(CONN), '5.0.7') !== -1) {
        //Für ältere Installation die init.php nachladen
        if (!defined('ILCH_DB_CHARSET') && file_exists('include/includes/init.php')) {
            require_once 'include/includes/init.php';
        }
        mysql_set_charset(ILCH_DB_CHARSET, CONN);
    }
    $timeZoneSetted = false;
    if (function_exists('date_default_timezone_get')) {
        $timeZoneSetted = mysql_query('SET time_zone = "' . date_default_timezone_get() . '"');
    }
    if (!$timeZoneSetted && version_compare(PHP_VERSION, '5.1.3')) {
        $timeZoneSetted = mysql_query('SET time_zone = "' . date('P') . '"');
    }
}
コード例 #19
0
ファイル: conexao.php プロジェクト: pereiraMichel/mapti
 public function getConnectionLocal()
 {
     try {
         $ini = parse_ini_file("config.ini", TRUE);
         $this->setLoginBanco(base64_decode($ini['local']['usuario']));
         $this->setSenhaBanco(base64_decode($ini['local']['senha']));
         $this->setServidorBanco(base64_decode($ini['local']['server']));
         $this->setPortaBanco(base64_decode($ini['local']['porta']));
         $this->setDatabase(base64_decode($ini['local']['database']));
         //            if(!isset(self::$instance)){
         //                self::$instance = new PDO('mysql:host=$this->servidor;dbname=$this->database', $this->loginBanco, $this->senhaBanco, array(PDO::MYSQL_ATTR_INIT_COMMAND=>"SET NAMES utf8"));
         //                self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         //                self::$instance->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING);
         //            }
         $conecta = mysql_connect($this->servidor, $this->loginBanco, $this->senhaBanco) or die("Erro ao conectar o banco de dados. Especificação técnica: " . mysql_connect_error());
         mysql_select_db($this->database, $conecta);
         mysql_set_charset('utf8', $conecta);
         //            $mysql = new mysqli($this->servidor, $this->loginBanco, $this->senhaBanco, $this->database, $this->porta);
         //            echo "Servidor: ".$this->servidor."\n";
         //            echo "Usuário: ".$this->loginBanco."\n";
         //            echo "Senha: ".$this->senhaBanco."\n";
         //            echo "Database: ".$this->database."\n";
         return $conecta;
         //            return self::$conecta;
         //            return self::$instance;
     } catch (Exception $ex) {
         echo "Ocorreu um erro na conexão. Erro: " . $ex->getMessage();
     }
 }
コード例 #20
0
ファイル: ajax_promo.php プロジェクト: davidkonrad/allearter
 private function drawList()
 {
     $html = '<div style="width:100%;clear:both;float:left;height:40px;"><hr></div><table style="clear:both;float:left;">';
     $html .= '<thead><th></th><th>Redigeret</th><th>Tekst</th><th>Søgning</th><th>Aktiv</th><th></th></thead><tbody>';
     //mysql_set_charset('Latin1');
     //$SQL='select id, changed, substr(content,1,60) as content, target, active from promos';
     $SQL = 'select id, changed, content, target, active from promos';
     mysql_set_charset('utf8');
     $result = $this->query($SQL);
     while ($row = mysql_fetch_array($result)) {
         $selected = $row['id'] == $this->selected_id ? ' class="selected"' : '';
         $html .= '<tr id="' . $row['id'] . '"' . $selected . '>';
         $html .= '<td><input type="button" value="Red." style="font-size:11px;" onclick="Promo.edit(' . $row['id'] . ');"/></td>';
         $html .= '<td>' . $row['changed'] . '</td>';
         $html .= '<td><div style="width:440px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">' . strip_tags($row['content']) . '</div></td>';
         $html .= '<td>' . $row['target'] . '</td>';
         $html .= '<td style="text-align:center;">';
         if ($row['active'] == '1') {
             $html .= '&#9679;';
         }
         $html .= '</td>';
         $html .= '<td><input type="button" value="Slet!" style="font-size:11px;" onclick="Promo.deletePromo(' . $row['id'] . ');"/></td>';
         $html .= '</tr>';
     }
     $html .= '</tbody></table>';
     echo $html;
 }
コード例 #21
0
/**
 * Establece una coneccion con la DB 
 * @return recurso MySql en exito
 * @return bool FALSE si hubo errores
 */
function conectarDB()
{
    global $_serverHost;
    global $_userName;
    global $_password;
    global $_schema;
    global $_char_set;
    global $archivoPHP;
    $retorno = false;
    $conn = @mysql_connect($_serverHost, $_userName, $_password);
    if ($conn == false) {
        gestionarError($archivoPHP, mysql_error());
        $retorno = false;
    } else {
        $esquema = mysql_select_db($_schema, $conn);
        if ($esquema == false) {
            gestionarError($archivoPHP, mysql_error());
            $retorno = false;
        } else {
            mysql_set_charset($_char_set, $conn);
            $retorno = $conn;
        }
    }
    return $retorno;
}
コード例 #22
0
ファイル: mysql.func.php プロジェクト: WeiGrand/phpShop
function connect()
{
    $link = mysql_connect(DB_HOST, DB_USER, DB_PWD) or die("连接数据库失败");
    mysql_set_charset(DB_CHARSET);
    mysql_select_db(DB_DBNAME) or die("指定数据库打开失败");
    return $link;
}
コード例 #23
0
 private function open()
 {
     $confDb = $this->confDb;
     $this->connection = mysql_connect($confDb['host'], $confDb['user'], $confDb['pass']);
     mysql_set_charset('utf8', $this->connection);
     mysql_select_db($confDb['dbname']);
 }
コード例 #24
0
ファイル: mysql.php プロジェクト: TinoDidriksen/pjj-chats
function SQLConnect()
{
    $db_server = "localhost";
    $db_username = "******";
    $db_password = "";
    $db_database = "pjj_chats";
    if (file_exists(__DIR__ . '/mysql-secret.php')) {
        include __DIR__ . '/mysql-secret.php';
    }
    $GLOBALS['handler'] = @mysql_pconnect($db_server, $db_username, $db_password);
    if ($GLOBALS['handler'] === FALSE) {
        echo '<b>MySQL connection failed. Trying to recover...</b><p>';
        usleep(200000);
        $GLOBALS['handler'] = @mysql_pconnect($db_server, $db_username, $db_password);
        if ($GLOBALS['handler'] === FALSE) {
            header('Refresh: 10; URL=' . $_SERVER['REQUEST_URI']);
            echo '<meta http-equiv="Refresh" content="10; URL=' . $_SERVER['REQUEST_URI'] . '">';
            echo '<p><b>The MySQL server is down or temporarily malfunctioning. <a href="javascript:history.go(0);">Reload the page.</a></b><p>';
            //			echo '<br><p><b><a href="http://board.projectjj.com/viewtopic.php?t=625">Read Me: Power Outage</a></b></p>';
            die;
        }
    }
    mysql_set_charset('utf8');
    mysql_select_db($db_database, $GLOBALS['handler']);
}
コード例 #25
0
ファイル: DBMysql.class.php プロジェクト: kkkyyy03/coffeemix
 /**
  * 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['host'], ':') === false && $connection['port']) {
         $connection['host'] .= ':' . $connection['port'];
     }
     // Attempt to connect
     $result = @mysql_connect($connection['host'], $connection['user'], $connection['pass']);
     if (!$result) {
         exit('Unable to connect to DB.');
     }
     if (mysql_error()) {
         $this->setError(mysql_errno(), mysql_error());
         return;
     }
     // Error appears if the version is lower than 4.1.13
     if (version_compare(mysql_get_server_info($result), '4.1.13', '<')) {
         $this->setError(-1, 'Rhymix requires MySQL 4.1.13 or later. Current MySQL version is ' . mysql_get_server_info());
         return;
     }
     // Set charset
     $this->charset = isset($connection['charset']) ? $connection['charset'] : 'utf8';
     mysql_set_charset($this->charset, $result);
     // select db
     @mysql_select_db($connection['database'], $result);
     if (mysql_error()) {
         $this->setError(mysql_errno(), mysql_error());
         return;
     }
     return $result;
 }
コード例 #26
0
 private function drawStatistik()
 {
     global $html;
     echo '<table class="stat"><thead>';
     $this->th('Artsgruppe');
     $this->th('Artsgruppe (dk)');
     $this->th('Arter');
     $this->th('Underarter');
     $this->th('Varieteter');
     $this->th('Former');
     $this->th('Hybrider');
     $this->th('Ikke accepterede arter');
     echo '</thead></tbody>';
     mysql_set_charset('utf8');
     $SQL = 'select distinct Artsgruppe from allearter order by Artsgruppe';
     // asc limit 1';
     $result = $this->query($SQL);
     $odd = false;
     while ($row = mysql_fetch_array($result)) {
         $this->drawStatistikItem($row['Artsgruppe'], $odd);
         $odd = $odd == false ? true : false;
     }
     echo '<tr><td colspan="2" class="total">Total</td>';
     echo '<td class="right total">' . $this->total['art'] . '</td>';
     echo '<td class="right total">' . $this->total['underart'] . '</td>';
     echo '<td class="right total ">' . $this->total['varietet'] . '</td>';
     echo '<td class="right total">' . $this->total['form'] . '</td>';
     echo '<td class="right total">' . $this->total['hybrid'] . '</td>';
     echo '<td class="right total">' . $this->total['accepteret'] . '</td>';
     echo '</tr>';
     echo '</tbody></table>';
 }
コード例 #27
0
ファイル: db.fn.php プロジェクト: boxcore/xspider
/**
 * 创建数据库连接
 * @param string $k 配置文件key
 * @return resource
 */
function db($k = 'default')
{
    $conf = conf('db', $k);
    if (!$conf) {
        trigger_error('Can\'t find $GLOBALS[\'db\'][\'' . $k . '\'] - in database.conf.php');
    }
    $db_key = md5("{$conf['hostname']}-{$conf['username']}-{$conf['password']}-{$conf['database']}");
    if (!isset($GLOBALS[$db_key])) {
        $server = $conf['hostname'] . ':' . $conf['port'];
        $link = mysql_connect($server, $conf['username'], $conf['password'], TRUE);
        if (!$link) {
            trigger_error('Connect database be fail, Pealse inspect yours database setting!');
        }
        if (!mysql_select_db($conf['database'], $link)) {
            trigger_error("Can't select database - {$conf['database']}, Pealse inspect yours database setting");
        }
        if (function_exists('mysql_set_charset')) {
            $is_set_charset = mysql_set_charset($conf['char_set']);
        } else {
            if (function_exists('mysqli_character_set_name')) {
                $is_set_charset = mysqli_character_set_name($conf['char_set']);
            } else {
                $is_set_charset = mysql_query("SET names '{$conf['char_set']}'");
            }
        }
        if ($is_set_charset != TRUE) {
            exit('charset error!');
        }
        //mysql_query( "SET names = '{$conf['char_set']}'" );
        mysql_query("SET CHARACTER SET '{$conf['char_set']}'");
        $GLOBALS[$db_key] = $link;
    }
    return $GLOBALS[$db_key];
}
コード例 #28
0
ファイル: DB.php プロジェクト: stereojesus/classes
 /**
  * Initial start params.
  */
 private function __construct()
 {
     $params = (include_once 'bootstrap.php');
     $connect = mysql_connect($params['db']['host'], $params['db']['user'], $params['db']['password']);
     mysql_set_charset($params['db']['charset'], $connect);
     mysql_select_db($params['db']['database']);
 }
コード例 #29
0
ファイル: db.php プロジェクト: elsayhsoft/fossil-grader
function connect_db()
{
    global $myserv;
    $myserv = mysql_connect("localhost", MYSQL_USER, MYSQL_PASSWD);
    mysql_select_db(MYSQL_DATABASE);
    mysql_set_charset('utf8');
}
コード例 #30
0
ファイル: referencer.php プロジェクト: davidkonrad/allearter
 private function drawReferences()
 {
     //$SQL='select distinct Referencenavn from allearter order by Referencenavn asc';
     $SQL = 'select distinct Referencetekst, Referencenavn from allearter order by Referencenavn asc';
     echo '<table class="stat" id="stat-referencer"><thead>';
     $this->th('Referencenavn', 200);
     $this->th('År', 30);
     $this->th('Referencetitel', 600);
     $this->th('Arter', 30);
     echo '</thead><tbody>';
     mysql_set_charset('utf8');
     $result = $this->query($SQL);
     $odd = false;
     $processed = array();
     while ($row = mysql_fetch_array($result)) {
         //$ref=$row['Referencenavn'];
         $ref = $row['Referencetekst'];
         if (!in_array($ref, $processed)) {
             if ($ref != '') {
                 $this->drawRow($ref, $odd);
                 $odd = $odd == false ? true : false;
             }
             $processed[] = $ref;
         }
     }
     echo '</tbody></table>';
 }