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


PHP dbClose函数代码示例

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


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

示例1: loginUser

function loginUser($con)
{
    $login_email = $con->real_escape_string($_POST['email']);
    $login_password = $con->real_escape_string(md5($_POST['password']));
    $return_url = base64_decode($_POST["return_url"]);
    $sql = $con->query("SELECT customer_id, customer_fname, customer_lname, email, password, level FROM customer WHERE email = '" . $login_email . "' AND password = '" . $login_password . "' ");
    $result = $sql->num_rows;
    if ($result > 0) {
        $row = $sql->fetch_assoc();
        if ($row) {
            $loggedin = array('loggedinemail' => $row['email'], 'loggedinfname' => $row['customer_fname'], 'loggedinlname' => $row['customer_lname'], 'loggedinpass' => $row['password']);
            $_SESSION['loggedin'] = $loggedin;
            //print_r($_SESSION['loggedin']);
            if (isset($_SESSION['loggedin'])) {
                header('location:' . $return_url);
            }
            /*				if($row['level'] == '1') {
            					$_SESSION['adminuser'] = 0;
            					header('location: main.php');
            				} elseif($row['level'] == '9') {
            					$_SESSION['adminuser'] = 1;
            					header('location:'. $current_url);
            				}			
            */
        }
        $sql->free_result();
    } else {
        echo 'Wrong email or password';
    }
    dbClose($con);
}
开发者ID:puppy09,项目名称:heels-commerce,代码行数:31,代码来源:login.php

示例2: db_query

function db_query($sql, $proxyFields)
{
    $con = dbConnect();
    if ($con == null) {
        return null;
    }
    foreach (array_keys($proxyFields) as $key) {
        $value = mysqli_real_escape_string($con, $proxyFields[$key]);
        if (is_string($value)) {
            $value = "\"{$value}\"";
        }
        $sql = str_replace($key, $value, $sql);
    }
    $result = mysqli_query($con, $sql);
    if (!$result) {
        echo "has error";
        print_r(debug_backtrace());
        $firstCall = end(debug_backtrace());
        $errMsg = "Error calling " . $firstCall["function"];
        $errMsg .= " on line " . $firstCall["line"];
        $errMsg .= " in " . $firstCall["file"] . ": " . mysqli_error($con);
        dbErrorMsg($errMsg);
        return false;
    } else {
        if (strpos($sql, "INSERT") !== false) {
            return mysqli_insert_id($con);
        } else {
            return new result($result);
        }
    }
    dbClose($con);
}
开发者ID:ChapResearch,项目名称:CROMA,代码行数:32,代码来源:drupalCompatibility.php

示例3: dbSelect

function dbSelect($con, $data)
{
    global $DEBUGMODE;
    $waypoints = array();
    $distance = 0;
    $slat = $data['slat'];
    $slon = $data['slon'];
    $elat = $data['elat'];
    $elon = $data['elon'];
    $distance = $data['d'];
    $theme = $data['t'];
    if ($DEBUGMODE) {
        echo "call haversine({$slat},{$slon},{$elat},{$elon},{$theme},{$distance})";
        print_r($data);
    }
    unset($data['d']);
    unset($data['t']);
    //GET THEMATIC ROUTES POIS FROM DATABASE
    $result = mysqli_query($con, "call haversine(" . $slat . "," . $slon . "," . $elat . "," . $elon . ",'" . $theme . "'," . $distance . ")");
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        $waypoints[] = $row;
    }
    sort($waypoints);
    filterWp($waypoints);
    if ($DEBUGMODE) {
        //echo "<pre>";
        print_r($waypoints);
        //echo "</pre>";
    }
    dbClose($con);
}
开发者ID:hotthess,项目名称:hot_thess,代码行数:31,代码来源:getThematicWp.php

示例4: findVersion

function findVersion()
{
    global $error, $conf_centreon;
    $db = dbConnect($conf_centreon['hostCentreon'], $conf_centreon['user'], $conf_centreon['password'], $conf_centreon['db'], true);
    $reqVersion = mysql_query("SELECT mod_release FROM modules_informations WHERE name='Discovery';");
    $version = mysql_fetch_array($reqVersion);
    return $version['mod_release'];
    dbClose($db);
}
开发者ID:chinaares,项目名称:centreon-discovery,代码行数:9,代码来源:informations.php

示例5: enterRecord

function enterRecord($name, $address, $latitude, $longitude, $type)
{
    $conn = dbconnect();
    $sql = "INSERT INTO markers (name, address, lat, lng, type)\n\tVALUES(" . "'" . $name . "', " . "'" . $address . "', " . "'" . $latitude . "', " . "'" . $longitude . "', " . "'" . $type . "')";
    if ($conn->query($sql) === TRUE) {
        echo "New record created successfully. <br />";
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
    dbClose($conn);
}
开发者ID:jlee736,项目名称:google-maps-tutorial-form,代码行数:11,代码来源:actions.php

示例6: createModuleCombo

function createModuleCombo()
{
    dbConnect();
    echo '<select name="id">';
    $res = dbQuery("SELECT M.`id-module`, M.intitule, D.intitule, M.no_semestre\r\n\r\n            FROM module M, diplome D \r\n\r\n            WHERE D.`id-diplome` = M.`id-diplome`\r\n\r\n            ORDER BY D.intitule, M.no_semestre");
    while ($row = mysql_fetch_array($res)) {
        echo '<option value="' . $row[0] . '">' . $row[2] . ' - SEM' . $row[3] . ' - ' . $row[1] . '</option>\\n';
    }
    echo '</select>';
    dbClose();
}
开发者ID:BackupTheBerlios,项目名称:sitebe-svn,代码行数:11,代码来源:wikifun.php

示例7: parseXMLStr

function parseXMLStr()
{
    global $HTTP_RAW_POST_DATA, $xmlResponse, $xmlMessage, $result, $con;
    if (dbConnect() == FALSE) {
        $xmlMessage .= "<status>Fail</status>";
        $xmlMessage .= "<info>Could not connect to the database</info>";
        return FALSE;
    }
    $fp = fopen("./Log/codes.xml", "w+");
    fwrite($fp, $HTTP_RAW_POST_DATA);
    fclose($fp);
    $xmldoc = domxml_open_file("./Log/codes.xml");
    $noderoot = $xmldoc->document_element();
    if ($noderoot->tagname = "insert") {
        $childnodes = $noderoot->child_nodes();
        foreach ($childnodes as $value) {
            if ($value->tagname == "area") {
                $area = $value->get_content();
            } else {
                if ($value->tagname == "assoc_code") {
                    $assoc_code = $value->get_content();
                } else {
                    if ($value->tagname == "paper_code") {
                        $paper_code = $value->get_content();
                    } else {
                        if ($value->tagname == "assoc_desc") {
                            $assoc_desc = $value->get_content();
                        } else {
                            if ($value->tagname == "paper_desc") {
                                $paper_desc = $value->get_content();
                            } else {
                                if ($value->tagname == "location") {
                                    $location = $value->get_content();
                                }
                            }
                        }
                    }
                }
            }
        }
        if (dbOperations($area, $assoc_code, $paper_code, $assoc_desc, $paper_desc, $location) == FALSE) {
            $xmlMessage .= "<status>Fail</status>";
            $xmlMessage .= "<info>Registration failed, try registering again</info>";
            $result = FALSE;
        }
    } else {
        $xmlMessage .= "<status>Fail</status>";
        $xmlMessage .= "<info>Wrong XMLRequest Format</info>";
        $result = FALSE;
    }
    dbClose();
    return $result;
}
开发者ID:sraj4,项目名称:EthicsPublicHtmlProd,代码行数:53,代码来源:CDE.php

示例8: getStatusById

function getStatusById($id)
{
    $connection = dbConnect();
    $options = ['columns' => 'id, status', 'where' => ['id' => $id]];
    $sql = buildSelect('status_atividade', $options);
    $stmt = mysqli_prepare($connection, $sql);
    mysqli_stmt_bind_param($stmt, 'i', $id);
    mysqli_stmt_execute($stmt);
    $resultObject = mysqli_stmt_get_result($stmt);
    $result = mysqli_fetch_all($resultObject, MYSQLI_ASSOC);
    mysqli_stmt_close($stmt);
    dbClose($connection);
    return $result[0];
}
开发者ID:Calcio,项目名称:CursoPHPBasico,代码行数:14,代码来源:queries.php

示例9: getUserById

function getUserById($id)
{
    $connection = dbConnect();
    $options = ['columns' => 'u.id_setor, u.nome, u.email, u.ativo, u.tipo, s.sigla, s.nome as setor', 'join' => [['type' => 'INNER JOIN', 'table' => 'setores s', 'columns' => 's.id = u.id_setor']], 'where' => ['u.id' => $id]];
    $sql = buildSelect('usuarios u', $options);
    $stmt = mysqli_prepare($connection, $sql);
    mysqli_stmt_bind_param($stmt, 'i', $id);
    mysqli_stmt_execute($stmt);
    $resultObject = mysqli_stmt_get_result($stmt);
    $result = mysqli_fetch_all($resultObject, MYSQLI_ASSOC);
    mysqli_stmt_close($stmt);
    dbClose($connection);
    return $result[0];
}
开发者ID:Calcio,项目名称:CursoPHPBasico,代码行数:14,代码来源:queries.php

示例10: dbConnect

function dbConnect()
{
    $con = mysqli_connect(DB_HOST, DB_USERNAME, DB_PASSWORD);
    if (mysqli_connect_errno()) {
        dbErrorMsg("Failed to connect to MySQL: " . mysqli_connect_error());
        return null;
    }
    $sql = "USE " . DB_DATABASE;
    if (!mysqli_query($con, $sql)) {
        dbErrorMsg("Failed to execute USE for the database: " . mysqli_error());
        dbClose($con);
        return null;
    }
    return $con;
}
开发者ID:ChapResearch,项目名称:CROMA,代码行数:15,代码来源:dbFunctions.php

示例11: getActivitiesById

function getActivitiesById($id)
{
    $connection = dbConnect();
    $options = ['columns' => 'a.id, a.id_demandante, a.id_responsavel, a.id_setor, a.id_status, a.descricao,
        ud.nome as demandante, s.sigla, sa.status, a.titulo, a.data, a.tempo_gasto', 'join' => [['type' => 'INNER JOIN', 'table' => 'setores s', 'columns' => 's.id = a.id_setor'], ['type' => 'INNER JOIN', 'table' => 'status_atividade sa', 'columns' => 'sa.id = a.id_status'], ['type' => 'INNER JOIN', 'table' => 'usuarios ud', 'columns' => 'ud.id = a.id_demandante']], 'where' => ['a.id' => $id]];
    $sql = buildSelect('atividades a', $options);
    $stmt = mysqli_prepare($connection, $sql);
    mysqli_stmt_bind_param($stmt, 'i', $id);
    mysqli_stmt_execute($stmt);
    $resultObject = mysqli_stmt_get_result($stmt);
    $result = mysqli_fetch_all($resultObject, MYSQLI_ASSOC);
    mysqli_stmt_close($stmt);
    dbClose($connection);
    return $result[0];
}
开发者ID:Calcio,项目名称:CursoPHPBasico,代码行数:15,代码来源:queries.php

示例12: panicExit

function panicExit(&$session, $errormsg)
{
    static $exitwiki = 0;
    global $dbi;
    if ($exitwiki) {
        // just in case CloseDataBase calls us
        exit;
    }
    $exitwiki = 1;
    if ($errormsg != '') {
        print "<P><hr noshade><h2>Schwerer Fehler</h2>\n";
        print $errormsg;
        print "\n</body></html>";
    }
    dbClose($session);
    exit;
}
开发者ID:BackupTheBerlios,项目名称:infobasar,代码行数:17,代码来源:util.php

示例13: dbUpdate

function dbUpdate($table, $modifyFields, $idName, $idValue, $idName2 = null, $idValue2 = null)
{
    $hadError = false;
    $con = dbConnect();
    if ($con == null) {
        return null;
    }
    if ($idName == "OID") {
        dbOrderNormalize2SQL($modifyFields);
    } else {
        if ($idName == "CID") {
            dbCustomerNormalize2SQL($modifyFields);
        }
    }
    $i = 1;
    $sql = "UPDATE {$table} SET ";
    foreach ($modifyFields as $column => $value) {
        // escape the incoming value to prevent SQL injection
        $safeValue = mysqli_real_escape_string($con, $value);
        // note that the PHP triple-equal is used here, it
        // specifies that the $value has to be explicitely null
        // as opposed to something that "looks" like null - like zero
        if ($value === null) {
            $sql .= "{$column} = NULL";
        } else {
            $sql .= "{$column} = '{$safeValue}'";
        }
        if ($i != sizeOf($modifyFields)) {
            $sql .= ", ";
        } else {
            $sql .= " ";
        }
        $i++;
    }
    $sql .= "WHERE {$idName} = {$idValue} ";
    if ($idName2 != null && $idValue2 != null) {
        $sql .= "AND {$idName2} = {$idValue2} ";
    } else {
        $sql .= "LIMIT 1;";
    }
    $result = mysqli_query($con, $sql);
    if (!$result) {
        dbErrorMsg("Error during sql insert in dbUpdate({$dbname})" . mysqli_error($con));
        $hadError = true;
    }
    dbClose($con);
    if (!$hadError) {
        return $idValue;
    } else {
        return 0;
    }
}
开发者ID:ChapResearch,项目名称:Online-Orders-Database,代码行数:52,代码来源:dbFunctions.php

示例14: addLink

 public function addLink($url)
 {
     $link = new Link();
     // On tente de charger le lien
     try {
         $link->load($url);
     } catch (Exception $e) {
         return "false";
     }
     /* --- Database --- */
     $subjectId = $this->subjectId($link->getSubjectName());
     if ($subjectId == false) {
         $subjectId = $this->addSubject($link->getSubjectName());
     }
     $query = "INSERT INTO link(link, name, subject_id) VALUES(\$\$" . pg_escape_string($link->getUrl()) . "\$\$, \$\$" . pg_escape_string($link->getName()) . "\$\$, " . pg_escape_string($subjectId) . ")";
     try {
         pg_query($query);
     } catch (Exception $e) {
         return "false";
     }
     if ($link != false) {
         $arr = array('link' => $link->getUrl(), 'name' => $link->getName(), 'subject_id' => $this->subjectId($link->getSubjectName()));
         return json_encode($arr);
     } else {
         return "false";
     }
     dbClose($db);
 }
开发者ID:skeggib,项目名称:cdi13,代码行数:28,代码来源:Database.php

示例15: doPost

function doPost()
{
    global $conf_centreon;
    $db = dbConnect($conf_centreon['hostCentreon'], $conf_centreon['user'], $conf_centreon['password'], $conf_centreon['db'], true);
    $error = 0;
    if (isset($_POST["submit"]) && $_POST["submit"] == "Add") {
        if (isset($_POST["os"]) && isset($_POST["template"])) {
            mysql_query("INSERT INTO mod_discovery_template_os_relation (os,template) VALUES('" . $_POST["os"] . "','" . $_POST["template"] . "');");
            $_POST = array();
        } else {
            $error = 1;
        }
    }
    if (isset($_POST["save"])) {
        /* Couleurs */
        if (isset($_POST['host_exists']) && isset($_POST['ip_exists']) && isset($_POST['host_missing']) && isset($_POST['consider_fqdn'])) {
            mysql_query("UPDATE mod_discovery_config SET host_exists_color='" . $_POST["host_exists"] . "', ip_exists_color='" . $_POST["ip_exists"] . "', host_missing_color='" . $_POST["host_missing"] . "', consider_fqdn='" . $_POST['consider_fqdn'] . "'") or die(mysql_error());
        }
        /* NMAP */
        if (isset($_POST["profil_nmap"])) {
            mysql_query("UPDATE mod_discovery_rangeip SET nmap_profil='" . $_POST["profil_nmap"] . "' WHERE id=0;");
        }
        if (isset($_POST["nmap_timeout"]) && is_int(intval($_POST["nmap_timeout"])) && $_POST["nmap_timeout"] >= 15000 && $_POST["nmap_timeout"] < 100000) {
            mysql_query("UPDATE mod_discovery_rangeip SET nmap_host_timeout='" . $_POST["nmap_timeout"] . "' WHERE id=0;");
        }
        if (isset($_POST["nmap_timeout_rtt"]) && is_int(intval($_POST["nmap_timeout_rtt"])) && $_POST["nmap_timeout_rtt"] >= 100 && $_POST["nmap_timeout_rtt"] < 10000) {
            mysql_query("UPDATE mod_discovery_rangeip SET nmap_max_rtt_timeout='" . $_POST["nmap_timeout_rtt"] . "' WHERE id=0;");
        }
        if (isset($_POST["nmap_retries"]) && is_int(intval($_POST["nmap_retries"])) && $_POST["nmap_retries"] >= 0 && $_POST["nmap_retries"] < 100) {
            mysql_query("UPDATE mod_discovery_rangeip SET nmap_max_retries='" . $_POST["nmap_retries"] . "' WHERE id=0;");
        }
        /* OID */
        if (isset($_POST["hostname"]) && !empty($_POST["hostname"]) && ereg("^(\\.([1-9][0-9]+|[0-9]))+\$", $_POST["hostname"])) {
            mysql_query("UPDATE mod_discovery_rangeip SET oid_hostname='" . $_POST["hostname"] . "' WHERE id=0;");
        }
        if (isset($_POST["OS"]) && !empty($_POST["OS"]) && ereg("^(\\.([1-9][0-9]+|[0-9]))+\$", $_POST["OS"])) {
            mysql_query("UPDATE mod_discovery_rangeip SET oid_os='" . $_POST["OS"] . "' WHERE id=0;");
        }
        /* SNMP */
        if (isset($_POST["version"])) {
            mysql_query("UPDATE mod_discovery_rangeip SET snmp_version='" . $_POST["version"] . "' WHERE id=0;");
        }
        if (isset($_POST["port"]) && is_int(intval($_POST["port"])) && $_POST["port"] > 0 && $_POST["port"] < 65536) {
            mysql_query("UPDATE mod_discovery_rangeip SET snmp_port='" . $_POST["port"] . "' WHERE id=0;");
        }
        if (isset($_POST["retries"]) && is_int(intval($_POST["retries"])) && $_POST["retries"] >= 0 && $_POST["retries"] < 100) {
            mysql_query("UPDATE mod_discovery_rangeip SET snmp_retries='" . $_POST["retries"] . "' WHERE id=0;");
        }
        if (isset($_POST["timeout"]) && is_int(intval($_POST["timeout"])) && $_POST["timeout"] > 0 && $_POST["timeout"] < 100) {
            mysql_query("UPDATE mod_discovery_rangeip SET snmp_timeout='" . $_POST["timeout"] . "' WHERE id=0;");
        }
        if (isset($_POST["community"]) && !strpos($_POST["community"], " ") && !empty($_POST["community"])) {
            mysql_query("UPDATE mod_discovery_rangeip SET snmp_community='" . $_POST["community"] . "' WHERE id=0;");
        }
        echo '<META HTTP-EQUIV="Refresh" CONTENT="1; URL=main.php?p=61203">';
        echo '<META HTTP-EQUIV="Refresh" CONTENT="1; URL=main.php?p=61203">';
    }
    if (isset($_POST["defaults"])) {
        $reqDefault = mysql_query("SELECT * FROM mod_discovery_rangeip WHERE id=-1;");
        while ($default = mysql_fetch_array($reqDefault, MYSQL_ASSOC)) {
            mysql_query("UPDATE mod_discovery_rangeip SET nmap_profil='" . $default['nmap_profil'] . "', nmap_host_timeout='" . $default['nmap_host_timeout'] . "', nmap_max_rtt_timeout='" . $default['nmap_max_rtt_timeout'] . "', nmap_max_retries='" . $default['nmap_max_retries'] . "', snmp_port='" . $default['snmp_port'] . "', snmp_retries='" . $default['snmp_retries'] . "', snmp_timeout='" . $default['snmp_timeout'] . "', snmp_community='" . $default['snmp_community'] . "', snmp_version='" . $default['snmp_version'] . "', oid_os='" . $default['oid_os'] . "', oid_hostname='" . $default['oid_hostname'] . "' WHERE id=0;");
        }
    }
    if (isset($_POST["clear"]) && $_POST["clear"] == " Clear All ") {
        mysql_query("DELETE FROM mod_discovery_template_os_relation");
    }
    if (!empty($_POST)) {
        $templateIDList = mysql_query("SELECT id FROM mod_discovery_template_os_relation;");
        while ($templateIDListData = mysql_fetch_array($templateIDList, MYSQL_ASSOC)) {
            $id = $templateIDListData["id"];
            $postVar = $id . "_x";
            if (isset($_POST[$postVar]) || isset($_POST[$id])) {
                mysql_query("DELETE FROM mod_discovery_template_os_relation WHERE id='" . $id . "';");
            }
        }
        unset($_POST);
    }
    if (isset($_GET["id"])) {
        $id = $_GET["id"];
        if ($id < 1 || $id > 2) {
            $id = 1;
        }
        doFormTab($id);
        doForm($id, $error);
    } else {
        doFormTab(1);
        doForm(1, $error);
    }
    dbClose($db);
}
开发者ID:chinaares,项目名称:centreon-discovery,代码行数:90,代码来源:configuration.php


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