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


PHP ConnectDB函数代码示例

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


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

示例1: getCurrentPlantStats

function getCurrentPlantStats($plantID)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $info = array();
    // Temperature
    $tempSQL = "SELECT * FROM `user_plant_stats` WHERE `pid` = '" . $plantID . "' AND `key` LIKE 'temperature' ORDER BY `timestamp` DESC LIMIT 1 ";
    $tempQuery = mysql_query($tempSQL) or die("Error getting temperature: " . mysql_error());
    while ($tempResults = mysql_fetch_assoc($tempQuery)) {
        $key = $tempResults["key"];
        $val = $tempResults["value"];
        $info["temp"] = $val;
    }
    // Light
    $lightSQL = "SELECT * FROM `user_plant_stats` WHERE `pid` = '" . $plantID . "' AND `key` LIKE 'light' ORDER BY `timestamp` DESC LIMIT 1 ";
    $lightQuery = mysql_query($lightSQL) or die("Error getting light: " . mysql_error());
    while ($lightResults = mysql_fetch_assoc($lightQuery)) {
        $key = $lightResults["key"];
        $val = $lightResults["value"];
        $info["light"] = $val;
    }
    /*
    	// Moisture
    	$moistSQL = "SELECT * FROM `user_plant_stats` WHERE `pid` = 11 AND `key` LIKE 'moisture' LIMIT 1 ";
    	$moistQuery = mysql_query($moistSQL) or die("Error getting moisture: " . mysql_error());
    
    	while($moistResults = mysql_fetch_assoc($moistQuery)){
    		$key = $moistResults["key"];
    		$val = $moistResults["value"];
    		$info[$key] = $val;
    	}*/
    echo json_encode($info);
    //$sql = "SELECT * FROM `user_plant_stats` WHERE `pid` = 11 AND `key` LIKE \'temperature\' LIMIT 0, 30 ";
}
开发者ID:andymikulski,项目名称:dotcom,代码行数:35,代码来源:DatabaseLego.php

示例2: setAlertType

function setAlertType($type)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $pattern = "/[^(\\d)]/";
    $replacement = '';
    $userID = $_REQUEST['uid'];
    $pID = $_REQUEST['pid'];
    $query = mysql_query("SELECT * FROM `user_plant_settings` WHERE `key` = 'Alert' AND `uid` =  {$userID} AND `pid` = {$pID}");
    if (mysql_num_rows($query) == 0) {
        $insertSQL = mysql_query("INSERT INTO `user_plant_settings` (`uid`, `pid`, `key`, `value`) VALUES ('" . $userID . "', '" . $pID . "', 'Alert', '" . $type . "')");
        if ($type == 'text') {
            $carrier = $_REQUEST['carrier'];
            $phoneNum = preg_replace($pattern, $replacement, $_REQUEST['num']);
            $updateQuery = mysql_query('UPDATE `' . $GLOBALS['DB'] . '`.`uc_users` SET `phone_number` = ' . $phoneNum . ', `carrier` = "' . $carrier . '"WHERE `id` = ' . $userID);
        }
    } else {
        $updateQuery = mysql_query("UPDATE `user_plant_settings` SET `key` = 'Alert',`value` = '" . $type . "' WHERE `uid` = {$userID} AND `pid` = {$pID}");
        if ($type == 'text') {
            $carrier = $_REQUEST['carrier'];
            $phoneNum = preg_replace($pattern, $replacement, $_REQUEST['num']);
            $updateQuery = mysql_query('UPDATE `' . $GLOBALS['DB'] . '`.`uc_users` SET `phone_number` = ' . $phoneNum . ', `carrier` = "' . $carrier . '" WHERE `id` = ' . $userID);
        }
    }
}
开发者ID:andymikulski,项目名称:dotcom,代码行数:26,代码来源:AlertLego.php

示例3: getOptimalSettings

function getOptimalSettings($plantID)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $info = array();
    // convert user plant id to plant type id
    $getQuery = "SELECT `type` FROM `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `id` = '" . $plantID . "' LIMIT 1";
    $getSQL = mysql_query($getQuery) or die("Error getting plants: " . mysql_error());
    while ($result = mysql_fetch_assoc($getSQL)) {
        $plantType = $result["type"];
    }
    // light
    $optLightSQL = "SELECT `value` FROM `plants` WHERE `pid` = '" . $plantType . "' AND `key` LIKE 'shade' LIMIT 1 ";
    $optLightQuery = mysql_query($optLightSQL) or die("Error getting light: " . mysql_error());
    while ($optLightResults = mysql_fetch_assoc($optLightQuery)) {
        $info["light"] = $optLightResults["value"];
    }
    // Temp
    $optTempSQL = "SELECT `value` FROM `plants` WHERE `pid` = '" . $plantType . "' AND `key` LIKE 'hardyness' LIMIT 1 ";
    $optTempQuery = mysql_query($optTempSQL) or die("Error getting temp: " . mysql_error());
    while ($optTempResults = mysql_fetch_assoc($optTempQuery)) {
        $info["temp"] = $optTempResults["value"];
    }
    // Water
    $optMoistureSQL = "SELECT `value` FROM `plants` WHERE `pid` = '" . $plantType . "' AND `key` LIKE 'moisture' LIMIT 1 ";
    $optMoistureQuery = mysql_query($optMoistureSQL) or die("Error getting temp: " . mysql_error());
    while ($optMoistureResults = mysql_fetch_assoc($optMoistureQuery)) {
        $info["moisture"] = $optMoistureResults["value"];
    }
    echo json_encode($info);
}
开发者ID:andymikulski,项目名称:dotcom,代码行数:32,代码来源:NotificationLego.php

示例4: init

function init()
{
    session_name("VarnerCC");
    session_start();
    session_cache_limiter('none');
    if (!isset($_SESSION["AdminID"])) {
        $_SESSION["AdminID"] = "";
    }
    if (!isset($_SESSION["UserID"])) {
        $_SESSION["UserID"] = "";
    }
    ConnectDB();
}
开发者ID:baltincsoft,项目名称:VarnerCC,代码行数:13,代码来源:ConfigFile.php

示例5: getSettings

function getSettings($uid, $pid)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $settingsSQL = "SELECT * FROM `" . $GLOBALS['DB'] . "`.`user_plant_settings` WHERE `pid` = '" . $pid . "' AND `uid` = '" . $uid . "'";
    $info = array();
    $setQuery = mysql_query($settingsSQL) or die('Error getting fun: ' . mysql_error());
    while ($setResults = mysql_fetch_assoc($setQuery)) {
        $key = $setResults["key"];
        $value = $setResults["value"];
        $info[$key] = $value;
    }
    return $info;
}
开发者ID:andymikulski,项目名称:dotcom,代码行数:15,代码来源:SettingsLego.php

示例6: getPlantData

function getPlantData($user, $id)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $getQuery = "SELECT * FROM `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `uid` = '" . $user . "' AND `id` = '" . $id . "' LIMIT 0, 50";
    $getSQL = mysql_query($getQuery) or die("Error getting plants: " . mysql_error());
    while ($result = mysql_fetch_assoc($getSQL)) {
        $info = array();
        $info["plantid"] = $result["id"];
        $info["typeid"] = $result["type"];
        $info["created"] = $result["timestamp"];
        $info["name"] = $result["name"];
        $deepSQL = "SELECT * FROM `" . $GLOBALS['DB'] . "`.`plants` WHERE `pid` = '" . $info["typeid"] . "' AND (`key` = 'common_name' OR `key` = 'latin_name')";
        $deepQuery = mysql_query($deepSQL) or die("Error getting deep plant info " . mysql_error());
        while ($deepResults = mysql_fetch_assoc($deepQuery)) {
            $key = $deepResults["key"];
            $val = $deepResults["value"];
            $info[$key] = $val;
        }
        $nextSQL = "SELECT id from `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `id` = (SELECT min(`id`) FROM `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `uid` = '" . $user . "' AND `id` > '" . $info["plantid"] . "') LIMIT 1";
        $nextQuery = mysql_query($nextSQL) or die("Error getting next: " . mysql_error());
        while ($nextResult = mysql_fetch_assoc($nextQuery)) {
            $info['next'] = $nextResult['id'];
        }
        $prevSQL = "SELECT id from `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `id` = (SELECT max(`id`) FROM `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `uid` = '" . $user . "' AND `id` < '" . $info["plantid"] . "') LIMIT 1";
        $prevQuery = mysql_query($prevSQL) or die("Error getting next: " . mysql_error());
        while ($prevResult = mysql_fetch_assoc($prevQuery)) {
            $info['prev'] = $prevResult['id'];
        }
        $deeperSQL = "SELECT * FROM `" . $GLOBALS['DB'] . "`.`user_plant_stuff` WHERE `pid` = '" . $info["plantid"] . "' AND `uid` = '" . $user . "'";
        $deeperQuery = mysql_query($deeperSQL) or die("Error getting deeper dashboard info " . mysql_error());
        while ($deeperResults = mysql_fetch_assoc($deeperQuery)) {
            $key = $deeperResults["key"];
            $val = $deeperResults["value"];
            $info[$key] = $val;
        }
        // printPlant($info);
        return $info;
    }
}
开发者ID:andymikulski,项目名称:dotcom,代码行数:41,代码来源:DashboardLego.php

示例7: LoadSettings

 public static function LoadSettings()
 {
     global $config, $db;
     if (!$db) {
         ConnectDB();
     }
     $result = mysql_query("SELECT `name`,`value` FROM `" . $config['table prefix'] . "Settings`", $db);
     if (!$result) {
         echo '<p>Failed to load settings from the database! The plugin may not have been loaded for the first time yet.</p>';
         exit;
     }
     if (mysql_num_rows($result) == 0) {
         return;
     }
     while (TRUE) {
         $row = mysql_fetch_assoc($result);
         if (!$row) {
             break;
         }
         $config['settings'][$row['name']] = array('value' => $row['value'], 'changed' => FALSE);
     }
 }
开发者ID:GRANTSWIM4,项目名称:WebAuctionPlus-1.2,代码行数:22,代码来源:settings.class.php

示例8: InquryByID

function InquryByID($_id)
{
    //echo "1.3-2";
    ConnectDB();
    $sql = "SELECT _content FROM `Soccer` WHERE _index='{$_id}'";
    $result = mysql_query($sql) or die('MySQL qsuery error');
    //echo $result;
    //echo "--: <br>";
    $_dataArray = array();
    while ($row = mysql_fetch_assoc($result)) {
        //mysql_fetch_array //assoc
        //echo "---<br>";
        //echo $row['_index']." : ".$row['_date']." : ".$row['_content'];
        //echo "<br>";
        $row['_content'] = htmlspecialchars($row['_content']);
        //restore HTML texts
        $row['_content'] = html_entity_decode($row['_content']);
        //reverse the process
        array_push($_dataArray, $row['_content']);
    }
    //echo "<br>";
    //return json_encode( $_dataArray );
    return $_dataArray;
}
开发者ID:seiran1944,项目名称:slate,代码行数:24,代码来源:DB_connection.php

示例9: VrDbFloors

function VrDbFloors()
{
    // Modified to exclude the "corrected" URLs !!
    set_time_limit(0);
    $parents = array();
    $fl = array();
    $floors = array();
    //$sql = "TRUNCATE TABLE KHovFeed.nf_redirected_url_db";
    //$db = ConnectDB();
    //$db->query($sql);
    $db = ConnectDB();
    $parents = CollectOld($db);
    mysqli_close($db);
    $i = 0;
    $db = ConnectDB();
    $stmt = $db->prepare("UPDATE kHovFeed.nf_redirected_url_db SET new_url=? WHERE old_url=?");
    foreach ($parents as $x => $y) {
        if (stripos($y, "?") !== FALSE) {
            // contains a ?+id strip it store as floor[$i]
            //  $fl = split("=",$y);
            //$floors[$i] = $fl[0]."=";
            /*'do nothing' on 'if' statement to exclude corrections*/
        } else {
            //does not.. reformat it with GetRedir store as floor[$i]
            $floors[$i] = GetRedir($y);
            $g = AppenFl($floors[$i], $db);
            $p = (string) $y;
            $f = (string) $g[0];
            if ($f == "") {
                $f = $p;
            }
            echo $f . " ";
            echo $p . " ";
            $stmt->bind_param("ss", $f, $p);
            $stmt->execute();
        }
        $i++;
    }
}
开发者ID:Scraps-Git,项目名称:PingPong,代码行数:39,代码来源:functions.php

示例10: define

<?php

define("ctlid_datatype_id", "dtid");
define("ctlid_scaling_factor_figures", "sff");
$includeRelPath = ".";
require_once "{$includeRelPath}/conndb/conndb.php";
require_once "{$includeRelPath}/lib/libhttp.php";
require_once "{$includeRelPath}/lib/htmldbutils.php";
$datatype_id = get_or_post_numeric(ctlid_datatype_id);
$scaling_factor_figures = cNull(get_or_post_numeric(ctlid_scaling_factor_figures), 15);
$connDB = ConnectDB();
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Health data visualization</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Visualisation des chiffres-clés des hôpitaux suisses">
    <meta name="author" content="Renaud Hirsch">

    <!-- Le styles -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <style>
      body {
        padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
      }
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet">

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
开发者ID:renozaf,项目名称:health_data_viz,代码行数:31,代码来源:starter.php

示例11: getKnownHazards

function getKnownHazards($pid)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $value = "";
    $query = mysql_query("SELECT `value` FROM `" . $GLOBALS['DB'] . "`.`plants` WHERE `pid` = {$pid} AND `key` = 'known_hazards'");
    while ($results = mysql_fetch_assoc($query)) {
        $value = $results["value"];
    }
    $value = stripBrackets($value);
    return "<p>{$value}</p>";
}
开发者ID:andymikulski,项目名称:dotcom,代码行数:13,代码来源:PlantLego.php

示例12: ConnectDB

    $db = ConnectDB();
    $sql = "TRUNCATE TABLE KHovFeed.cb_community_hd_db";
    $db->query($sql);
}
if (isset($_POST['clean_bqmi'])) {
    $db = ConnectDB();
    $sql = "TRUNCATE TABLE KHovFeed.boyl_qmi";
    $db->query($sql);
}
if (isset($_POST['clean_cbqmi'])) {
    $db = ConnectDB();
    $sql = "TRUNCATE TABLE KHovFeed.cb_community_qmi_db";
    $db->query($sql);
}
if (isset($_POST['init'])) {
    $db = ConnectDB();
    $sql = "TRUNCATE TABLE KHovFeed.nf_redirected_url_db";
    $db->query($sql);
}
if (isset($_POST['eval'])) {
    $url = "http://nochrome.fusionatthemeadows.khov.ml3ds-cloud.com/resources/data/CommunityData/fusionatthemeadows.khov.ml3ds-cloud.com";
    //$url = "http://www.khov.com/find-new-homes/arizona/peoria/85383/k-hovnanian-homes/fusion-at-the-meadows";
    //$rawDat = file_get_contents($url);
    //print_r($rawDat);
    EvalSource($url);
}
?>


<!DOCTYPE html>
<html>
开发者ID:Scraps-Git,项目名称:PingPong,代码行数:31,代码来源:index.php

示例13: define

define("FB_API_KEY" , "148451281843294");
define("FB_SECRET" , "69de471eb988025ca0b7a23a4bf632fc");

function ConnectDB() {
	$host="localhost"; // Host name.
	$db_user="root"; // MySQL username.
	$db_password="root"; // MySQL password.
	$database="wroupon"; // Database name.
	if (mysql_connect( $host, $db_user, $db_password ) && mysql_select_db($database)) return 1;	else return 0;
}

//
// the php facebook api downloaded at step 3
include("facebook-client/facebook.php");

if(!ConnectDB()) die;

//
// start facebook api with the codes defined in step 1.
$fb=new Facebook( FB_API_KEY , FB_SECRET );
$fb_user=$fb->get_loggedin_user();
$out="";

if($fb_user) {
	// if we already have a user ID cookie than we link
	// in the database this user with his facebook account
	// using the fb_userid field.
	// this code assumes that when a user login in your
	// community you set up a value in a cookie called "myid".
	// this cookie is the one that you use when you want
	// to remember the user:
开发者ID:jowino,项目名称:bd786110cact,代码行数:31,代码来源:index.php

示例14: putenv

    print "Malloc scribbling enabled.\n";
    putenv("MallocLogFile=/dev/null");
    putenv("MallocScribble=1");
    putenv("MallocPreScribble=1");
    putenv("MallocGuardEdges=1");
}
require_once "helpers.inc";
/////////////
// run tests
/////////////
if (IsModelGenMode()) {
    print "GENERATING REFERENCE TEST RESULTS\n\n";
} else {
    print "PERFORMING AUTOMATED TESTING\n\n";
}
$testconn = ConnectDB();
if (mysqli_connect_error()) {
    print "ERROR: failed to connect to MySQL: " . mysqli_connect_error() . "\n";
    exit(1);
} else {
    $testconn->close();
}
$t = MyMicrotime();
// build test lists
$tests = array();
$dh = opendir(".");
$user_skipped = 0;
while ($entry = readdir($dh)) {
    if (substr($entry, 0, 5) != "test_") {
        continue;
    }
开发者ID:ravelry,项目名称:sphinx,代码行数:31,代码来源:ubertest.php

示例15: real_htmlspecialchars

                <td colspan="2" height="40">&nbsp;<td>
          </tr>
        </table>
</form>



<?php 
function real_htmlspecialchars($string)
{
    return htmlspecialchars($string, ENT_QUOTES, "UTF-8");
}
$submit = $_REQUEST['submit'];
if ($submit) {
    include "inc.functions.php";
    @ConnectDB();
    @session_start();
    $username = real_htmlspecialchars($_REQUEST['username']);
    $passwort = real_htmlspecialchars($_REQUEST['passwort']);
    $sql = "SELECT username, passwort FROM {$user_table} WHERE username = '{$username}' AND passwort = '{$passwort}' LIMIT 1";
    $result = mysql_query($sql);
    $row = mysql_fetch_row($result);
    if ($row[0] == "") {
        echo "<span class='text'><font color='#FF0000'>Benutzername und/oder Passwort waren falsch.</font></span>";
    } else {
        //$HTTP_SESSION_VARS["username"] = $username;
        $_SESSION['username'] = $username;
        //echo "<span class=text>Login erfolgreich.</span>";
        echo "<meta http-equiv=\"refresh\" content=\"0; URL=show.php?AuflistungsArt=alles\">";
    }
    //end if
开发者ID:haraldmueller,项目名称:lcmeilen.ch,代码行数:31,代码来源:admin_login.php


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