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


PHP db_open函数代码示例

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


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

示例1: insertAIML

function insertAIML()
{
    //db globals
    global $template, $msg;
    $dbconn = db_open();
    $aiml = "<category><pattern>[pattern]</pattern>[thatpattern]<template>[template]</template></category>";
    $aimltemplate = mysql_real_escape_string(trim($_POST['template']));
    $pattern = strtoupper(mysql_real_escape_string(trim($_POST['pattern'])));
    $thatpattern = strtoupper(mysql_real_escape_string(trim($_POST['thatpattern'])));
    $aiml = str_replace('[pattern]', $pattern, $aiml);
    $aiml = empty($thatpattern) ? str_replace('[thatpattern]', "<that>{$thatpattern}</that>", $aiml) : $aiml;
    $aiml = str_replace('[template]', $aimltemplate, $aiml);
    $topic = strtoupper(mysql_real_escape_string(trim($_POST['topic'])));
    $bot_id = isset($_SESSION['poadmin']['bot_id']) ? $_SESSION['poadmin']['bot_id'] : 1;
    if ($pattern == "" || $template == "") {
        $msg = 'You must enter a user input and bot response.';
    } else {
        $sql = "INSERT INTO `aiml` (`id`,`bot_id`, `aiml`, `pattern`,`thatpattern`,`template`,`topic`,`filename`, `php_code`) VALUES (NULL,'{$bot_id}', '{$aiml}','{$pattern}','{$thatpattern}','{$aimltemplate}','{$topic}','admin_added.aiml', '')";
        $result = mysql_query($sql, $dbconn) or die('You have a SQL error on line ' . __LINE__ . ' of ' . __FILE__ . '. Error message is: ' . mysql_error() . ".<br />\nSQL = {$sql}<br />\n");
        if ($result) {
            $msg = "AIML added.";
        } else {
            $msg = "There was a problem adding the AIML - no changes made.";
        }
    }
    mysql_close($dbconn);
    return $msg;
}
开发者ID:massyao,项目名称:chatbot,代码行数:28,代码来源:teach.php

示例2: db_generate

function db_generate($fname, $db = false)
{
    global $dbh;
    if (!$db) {
        $db = db_open($fname);
        if (!$db) {
            die('db open failed!');
        }
    }
    $dbh = $db;
    $qa[] = "CREATE TABLE users (uid INTEGER PRIMARY KEY ASC, user TEXT, pass TEXT, name TEXT, email TEXT);";
    $qa[] = "CREATE TABLE groups (gid INTEGER PRIMARY KEY ASC, name TEXT, belongsto TEXT);";
    $qa[] = "CREATE TABLE categories (cid INTEGER PRIMARY KEY ASC, title TEXT, gids TEXT);";
    $qa[] = "CREATE TABLE posts (pid INTEGER PRIMARY KEY ASC, title TEXT, text TEXT, cid INTEGER);";
    $qa[] = "CREATE TABLE msgs (mid INTEGER PRIMARY KEY ASC, from_id INTEGER, to_id INTEGER, msg TEXT, files TEXT);";
    $qa[] = "CREATE TABLE files (fid INTEGER PRIMARY KEY ASC, up_user_id INTEGER, file TEXT);";
    $qa[] = "CREATE TABLE news (nid INTEGER PRIMARY KEY ASC, ts INTEGER, content TEXT);";
    $qa[] = "CREATE TABLE admin (name TEXT);";
    $qa[] = "INSERT INTO users VALUES (NULL,'admin','" . sha1(sha1('KolohMun7p')) . "','Administrator','admin@binaryrebels.org')";
    $qa[] = "INSERT INTO groups VALUES (NULL,'admin','1')";
    $qa[] = "INSERT INTO groups VALUES (NULL,'everyone','1')";
    $qa[] = "INSERT INTO categories VALUES (NULL,'carders','1,2')";
    $qa[] = "INSERT INTO categories VALUES (NULL,'xploits','1,2')";
    $qa[] = "INSERT INTO categories VALUES (NULL,'0days','1,2')";
    $qa[] = "INSERT INTO categories VALUES (NULL,'XSS','1,2')";
    $qa[] = "INSERT INTO categories VALUES (NULL,'sql injections','1,2')";
    $qa[] = "INSERT INTO news VALUES (NULL, '" . time() . "','rwthctf has started, have fun hacking and good luck(-:')";
    foreach ($qa as $q) {
        db_query($q, $dbh);
    }
    echo 'Database initialized:-)' . "\n";
    return $dbh;
}
开发者ID:vulnerabilityCode,项目名称:ctf,代码行数:33,代码来源:sqlite.inc.php

示例3: execQuery

function execQuery($query)
{
    $conn = db_open();
    $rs = mysql_query($query, $conn);
    // or die (mysql_error());
    db_close($conn);
    return $rs;
}
开发者ID:jesseoliveira,项目名称:e-sic-livre-git,代码行数:8,代码来源:database.php

示例4: db_make_safe

/**
 * function db_make_safe()
 * Makes a str safe to insert in the db
 * @param string $str - the string to make safe
 * @return string $str - the safe string
**/
function db_make_safe($str)
{
    $dbconn = db_open();
    $out = mysql_real_escape_string($str, $dbconn);
    // Takes into account the character set of the chosen database
    mysql_close($dbconn);
    return $out;
}
开发者ID:massyao,项目名称:chatbot,代码行数:14,代码来源:db_functions.php

示例5: return_device

function return_device($device_id)
{
    $con = db_open();
    $sql = "\r\n\t\tSELECT owner ,device_id , type_id, type , sensitivity, offset, last_calibrated \r\n\t\tFROM sensors INNER JOIN sensorboards \r\n\t\tON sensor_id=id_co2 OR sensor_id=id_co OR sensor_id=id_pm10 OR sensor_id=id_pm25 \r\n\t\tOR sensor_id=id_no OR sensor_id=id_no2 OR sensor_id=id_so2 OR sensor_id=id_o3\r\n\t\tWHERE `device_id`={$device_id}\r\n\t\t";
    $result = mysql_query($sql, $con);
    $xml = generate_calibxml($result);
    echo $xml;
}
开发者ID:unswjasonhu,项目名称:airpollution_modeling,代码行数:8,代码来源:get-calib-constants-original.php

示例6: connect_to_db

function connect_to_db($query)
{
    $con = db_open();
    $result = mysql_query($query, $con);
    if (!$result) {
        die("Invalid query: " . mysql_error());
    }
    return $result;
}
开发者ID:unswjasonhu,项目名称:airpollution_modeling,代码行数:9,代码来源:query_todb.php

示例7: sample_group_create

function sample_group_create($user_id, $comment = NULL)
{
    $con = db_open();
    $sql = sample_group_insert_SQL($user_id, $comment);
    db_table_lock("SampleGroups", $con);
    $result = mysql_query($sql, $con);
    $id = mysql_insert_id($con);
    db_table_unlock($con);
    return $id;
}
开发者ID:unswjasonhu,项目名称:airpollution_modeling,代码行数:10,代码来源:sample-group.php

示例8: getDbTime

function getDbTime()
{
    $dbase = db_open($dbase);
    if (!$dbase) {
        echo "<font class='error'>ERROR</font> : cannot open DB<br>";
        exit;
    }
    $sql = "SELECT UNIX_TIMESTAMP( CONVERT_TZ(now(),@@time_zone,'+0:00') )";
    $res = mysqli_query($dbase, $sql);
    if (!@$res) {
        writelog("error.log", "Wrong query : \" {$sql} \"");
        echo "<font class='error'>ERROR</font> : Wrong query : {$sql}<br><br>";
        exit;
    }
    list($date) = mysqli_fetch_row($res);
    db_close($dbase);
    return $date;
}
开发者ID:ap0110,项目名称:DarkArts,代码行数:18,代码来源:mod_dbtime.php

示例9: stats_get_num_samples

function stats_get_num_samples(&$samples_today)
{
    global $con;
    $con = db_open();
    $today = strtotime(date('Y-m-d', time()));
    $total_count = 0;
    $today_count = 0;
    $sql = "SELECT `date` FROM `Samples`";
    $result = mysql_query($sql, $con);
    while ($row = mysql_fetch_assoc($result)) {
        $date = strtotime($row['date']);
        if ($date >= $today) {
            $today_count++;
        }
        $total_count++;
    }
    $samples_today = $today_count;
    return $total_count;
}
开发者ID:unswjasonhu,项目名称:airpollution_modeling,代码行数:19,代码来源:stats.php

示例10: getChatLines

function getChatLines($i, $j)
{
    global $bot_id;
    $dbconn = db_open();
    $sql = <<<endSQL
SELECT AVG(`chatlines`) AS TOT
\t\t\t\tFROM `users`
\t\t\t\tINNER JOIN `conversation_log` ON `users`.`id` = `conversation_log`.`userid`
\t\t\t\tWHERE `conversation_log`.`bot_id` = {$bot_id} AND [endCondition];
endSQL;
    if ($i == "average") {
        $endCondition = '`chatlines` != 0;';
    } else {
        $endCondition = "(`chatlines` >= {$i} AND `chatlines` <= {$j})";
    }
    $sql = str_replace('[endCondition]', $endCondition, $sql);
    //get undefined defaults from the db
    $result = mysql_query($sql, $dbconn) or die('You have a SQL error on line ' . __LINE__ . ' of ' . __FILE__ . '. Error message is: ' . mysql_error() . ".<br />\nSQL = {$sql}<br />\n");
    $row = mysql_fetch_assoc($result);
    $res = $row['TOT'];
    return $res;
}
开发者ID:massyao,项目名称:chatbot,代码行数:22,代码来源:stats.php

示例11: showChatFrame

function showChatFrame()
{
    global $template, $bot_name, $bot_id;
    $dbconn = db_open();
    $sql = "select `format` from `bots` where `bot_id` = {$bot_id} limit 1;";
    $result = mysql_query($sql, $dbconn) or die('You have a SQL error on line ' . __LINE__ . ' of ' . __FILE__ . '. Error message is: ' . mysql_error() . ".<br />\nSQL = {$sql}<br />\n");
    $row = mysql_fetch_assoc($result);
    $format = strtolower($row['format']);
    switch ($format) {
        case "html":
            $url = '../gui/plain/';
            break;
        case "json":
            $url = '../gui/jquery/';
            break;
        case "xml":
            $url = '../gui/xml/';
            break;
    }
    $out = $template->getSection('ChatDemo');
    $out = str_replace('[pageSource]', $url, $out);
    $out = str_replace('[format]', strtoupper($format), $out);
    return $out;
}
开发者ID:massyao,项目名称:chatbot,代码行数:24,代码来源:demochat.php

示例12: db_open

<?php

require_once 'db-config.php';
db_open("pulmofluency");
session_start();
$userid = $_SESSION['user_id'];
$locSelected = $_GET['locSelected'];
$userIsReviewer = $_GET['userIsReviewer'];
// Escape User Input to help prevent SQL Injection
$locSelected = mysql_real_escape_string($locSelected);
$userIsReviewer = mysql_real_escape_string($userIsReviewer);
$location = explode("~", $locSelected);
// Build SQL
// Build SELECT statement
$sqlselect = 'SELECT users.firstname, users.lastname, users.ID';
// Build FROM statement
if ($userIsReviewer != "1") {
    $sqlfrom = ' FROM users';
} else {
    $sqlfrom = ' FROM peerreview, users';
}
// Build WHERE statement
if ($userIsReviewer != "1") {
    $sqlwhere = ' WHERE role="2"';
} else {
    $sqlwhere = ' WHERE role="2" AND (peerreview.reviewer = "' . $userid . '") AND (users.ID = peerreview.reviewee)';
}
$sqlwhere2 = "";
if ($location) {
    $kv = array();
    foreach ($location as $key => $value) {
开发者ID:RootLoudDev,项目名称:fluency_tool,代码行数:31,代码来源:managerData.php

示例13: param

if (0) {
    // quitamos esto del medio de momento - lo de artistas_etc4.php
    // son 3 relaciones 1 a N - artistas -> albumes -> canciones -> videos
    // PROGRAMA PRINCIPAL
    // usa unordered lists, se puede presentar algo mejor con un poco de CSS
    // los parametros del script: co(ntinente) pa(is) ci(udad)
    param("ar", $ar);
    // param() cambia(defina) el valor de la variable(global) 2º argumento
    param("al", $al);
    // mira lo que hace extract(), todavía no lo uso aquí
    param("ca", $ca);
    // seria buena idea si son muchos parametros
    param("vi", $vi);
    // empezamos el query string para pasarlo a hacer_lista()
    $qs = "{$yo}?";
    $con = db_open($db_name);
    echo "KEYS:", br();
    foreach (["artistas", "albumes", "canciones", "videos"] as $t) {
        echo "{$t} PK: ", db_getPK($db_name, $t), br();
        $ka = db_getFK($db_name, $t);
        if ($ka[0]) {
            echo "{$t} FK: " . $ka[1][0][0] . " ref tabla " . $ka[1][0][1] . " col " . $ka[1][0][2] . br();
        }
        PC::db($ka, "{$t}");
        $rfk = db_getrFK($db_name, $t);
        if ($rfk[0]) {
            echo "Referencias a {$t}: ", table($rfk[0], $rfk[1]);
        }
    }
    // empezamos por las canciones de momento, luego veremos que hacer con los videos
    if ($ca) {
开发者ID:plamencurso,项目名称:myphpinc,代码行数:31,代码来源:revistas.php

示例14: solusvmcontrol_summary_tab

function solusvmcontrol_summary_tab()
{
    // Make sure subtab is set
    if (!isset($_GET['subtab'])) {
        $_GET['subtab'] = "active";
    }
    // Tab styling
    $activestyle = " style=\"background-color: #FFF !important;border-bottom:solid 1px white !important;\"";
    $out_inactive = false;
    $out_active = false;
    $out_all = false;
    switch ($_GET['subtab']) {
        case "inactive":
            $active_in = $activestyle;
            $out_inactive = true;
            break;
        case "all":
            $active_al = $activestyle;
            $out_all = true;
            break;
        case "active":
        default:
            $active_ac = $activestyle;
            $out_active = true;
            break;
            // This looks a bit confusing, but basically case "active" is the default
    }
    // Init arrays for output
    $active = "";
    $inactive = "";
    $all = "";
    // Init query
    db_open();
    $svmc_servers_query = "SELECT group_concat(DISTINCT relid SEPARATOR ',') AS svmc_servers FROM tblcustomfields WHERE (fieldname = 'solusvm_server' OR  fieldname = 'solusvm_api_key' OR fieldname = 'solusvm_api_hash')";
    $svmc_servers_result = mysql_query($svmc_servers_query);
    // Get the login Credentials into an assoc array
    $svmc_servers = mysql_fetch_assoc($svmc_servers_result);
    if (empty($svmc_servers["svmc_servers"])) {
        $out = "<tr><td colspan=\"3\">SolusVMControl is not currently active on any of your VPS.</td></tr>";
    } else {
        // Get all VPS
        $all_vps_result = mysql_query("SELECT tblhosting.*, tblproducts.name FROM tblhosting, tblproducts WHERE tblhosting.packageid IN ({$svmc_servers["svmc_servers"]}) AND tblhosting.packageid = tblproducts.id");
        $all_vps = null;
        while ($row = mysql_fetch_assoc($all_vps_result)) {
            $all_vps[] = $row;
        }
        // Itterate through $all_vps
        foreach ($all_vps as $vps) {
            // Get credentials for $vps
            $vps_svmc_settings_result = mysql_query("SELECT tblcustomfieldsvalues.relid,fieldname,value FROM tblcustomfields, tblcustomfieldsvalues WHERE tblcustomfields.id = tblcustomfieldsvalues.fieldid AND fieldname LIKE 'solusvm_%' AND tblcustomfieldsvalues.relid = '" . $vps['id'] . "'");
            $vps_svmc_settings = null;
            while ($row = mysql_fetch_assoc($vps_svmc_settings_result)) {
                $vps_svmc_settings[] = $row;
            }
            // Pick up VPS with no details logged
            if (sizeof($vps_svmc_settings) < 3) {
                $inactive[$vps['id']]['name'] = $vps['name'];
                $inactive[$vps['id']]['domain'] = rtrim($vps['domain'], '. ');
                $inactive[$vps['id']]['id'] = $vps['id'];
            }
            // Sort the results
            foreach ($vps_svmc_settings as $vps_svmc_settings_item) {
                // Create output arrays
                $active[$vps['id']][$vps_svmc_settings_item['fieldname']] = $vps_svmc_settings_item['value'];
                $active[$vps['id']]['name'] = $vps['name'];
                $active[$vps['id']]['domain'] = rtrim($vps['domain'], '. ');
                $active[$vps['id']]['id'] = $vps['id'];
            }
        }
    }
    // Check through the active ones (as some may not actually be active (empty))
    if (!empty($active)) {
        foreach ($active as $active_item) {
            if (empty($active_item['solusvm_api_key']) || empty($active_item['solusvm_api_hash']) || empty($active_item['solusvm_server'])) {
                $inactive[] = $active_item;
                unset($active[$active_item['id']]);
            }
        }
    }
    if ($out_active) {
        $outrows = $active;
    } else {
        if ($out_inactive) {
            $outrows = $inactive;
        } else {
            if ($out_all) {
                $outrows = array_merge($active, $inactive);
            }
        }
    }
    if (!empty($outrows)) {
        $i = 0;
        foreach ($outrows as $row) {
            if ($i % 2) {
                $switch = "";
            } else {
                $switch = "background-color:#F5F5F5";
            }
            $out .= "\n\t\t\t<tr style=\"height:50px;{$switch}\">" . "\n\t\t\t\t<td>{$row['name']}</td>" . "\n\t\t\t\t<td><a href=\"clientshosting.php?id={$row['id']}\">{$row['domain']}</a></td>";
            if (($out_active || $out_all) && !empty($row['solusvm_server'])) {
//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:SolusVMControl,代码行数:101,代码来源:solusvmcontrol.php

示例15: db_switch

function db_switch($target = false)
{
    global $_josh;
    db_open();
    if (!$target) {
        $target = $_josh["db"]["database"];
    }
    if ($_josh["db"]["language"] == "mssql") {
        mssql_select_db($target, $_josh["db"]["pointer"]);
    } elseif ($_josh["db"]["language"] == "mysql") {
        mysql_select_db($target, $_josh["db"]["pointer"]);
    }
    $_josh["db"]["switched"] = $target == $_josh["db"]["database"] ? false : true;
}
开发者ID:joshreisner,项目名称:hcfa-cc,代码行数:14,代码来源:db.php


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