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


PHP connectToDB函数代码示例

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


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

示例1: emailcheck

function emailcheck()
{
    $dbc = connectToDB("leeawg");
    $join_name = $_POST['name'];
    $join_email = $_POST['email'];
    $join_username = $_POST['username'];
    $join_password = $_POST['password'];
    $join_securepw = sha1($join_password);
    $join_age = $_POST['age'];
    $q_emailCheck = "SELECT email FROM account WHERE email = '{$join_email}';";
    $q_usernameCheck = "SELECT user_id FROM account WHERE user_id = '{$join_username}';";
    $emailCheck_result = performQuery($dbc, $q_emailCheck);
    $emailCheck_duplicate = mysqli_fetch_array($emailCheck_result, MYSQLI_ASSOC);
    $usernameCheck_result = performQuery($dbc, $q_usernameCheck);
    $usernameCheck_duplicate = mysqli_fetch_array($usernameCheck_result, MYSQLI_ASSOC);
    if (mysqli_num_rows($usernameCheck_result) == 0 && mysqli_num_rows($emailCheck_result) == 0) {
        //echo "no duplicate :)";
        $query = "INSERT INTO account (user_id,password,name,age,email)\n\t\tVALUES ( '{$join_username}', '{$join_securepw}', '{$join_name}', '{$join_age}', '{$join_email}' )";
        insert($dbc, $query);
    }
    if (mysqli_num_rows($emailCheck_result) > 0) {
        errorform('email');
    }
    if (mysqli_num_rows($usernameCheck_result) > 0) {
        errorform('username');
    }
}
开发者ID:smblee,项目名称:smblee.github.io,代码行数:27,代码来源:dboperation.php

示例2: changePass

function changePass($user, $password, $password2)
{
    if (empty($user) || empty($password) || empty($password2)) {
        //empty username and password
        return false;
    }
    if ($password != $password2) {
        echo "the passwords didn't match ";
        return false;
    }
    $conn = connectToDB();
    if (!$conn) {
        echo "conn failure ";
        return false;
    }
    $stmnt2 = $conn->prepare("SELECT * FROM USERS2 WHERE USER_UID = ?;");
    $stmnt2->bind_param('s', $user);
    $stmnt2->execute();
    $stmnt2->store_result();
    $amount = $stmnt2->num_rows;
    if ($amount == 0) {
        echo "user does not exists ";
        return false;
    }
    $stmnt2->close();
    $stmnt = $conn->prepare("UPDATE USERS2 SET USER_PWDHSH=?, USER_PWDSALT= ? WHERE USER_UID = ?;");
    $salt = file_get_contents('/dev/urandom', false, null, 0, 64);
    $options = array('salt' => $salt);
    $phash = crypt($password, $salt);
    $stmnt->bind_param('sss', $phash, $salt, $user);
    $stmnt->execute();
    $stmnt->close();
    $conn->close();
    return true;
}
开发者ID:Alzheimers480,项目名称:server,代码行数:35,代码来源:changepass.php

示例3: getQuestions

 function getQuestions($sid, $type)
 {
     // This file looks up all questions associated with a given session. It's designed
     // for use with the student home page, so its only parameter is the session ID,
     // and it doesn't support any sorting or filtering of the data.
     $db_conn = connectToDB();
     // Since we want data for the autocomplete box, we want to get
     // all questions and feedback in the database.
     $rows = array();
     if ($type == 'Q') {
         // Query Question and fetch results
         $query = sprintf("SELECT * FROM Question WHERE sid = %d", $sid);
         $results = mysql_query($query, $db_conn);
         if (!$results) {
             die("Error: " . mysql_error($db_conn));
         }
         while ($r = mysql_fetch_assoc($results)) {
             $rows[] = array('text' => $r["text"], 'votes' => $r["numvotes"], 'answered' => $r["answered"], 'type' => 'Q');
         }
     } elseif ($type == 'F') {
         // Query Feedback and fetch results
         $query = sprintf("SELECT * FROM Feedback WHERE sid = %d", $sid);
         $results = mysql_query($query, $db_conn);
         if (!$results) {
             die("Error: " . mysql_error($db_conn));
         }
         while ($r = mysql_fetch_assoc($results)) {
             $rows[] = array('text' => $r["text"], 'votes' => $r["numvotes"], 'isread' => $r["isread"], 'type' => 'F');
         }
     }
     mysql_close($db_conn);
     return $rows;
 }
开发者ID:kumarsivarajan,项目名称:classroom-presenter,代码行数:33,代码来源:studenthome_lookup_questions.php

示例4: newAcqua

function newAcqua($username, $fname, $lname)
{
    if (empty($username) | empty($fname) | empty($lname)) {
        echo "one or more paramters missing ";
        return false;
    }
    $conn = connectToDB();
    if (!$conn) {
        echo "conn failure ";
        return false;
    }
    $stmnt2 = $conn->prepare("SELECT * FROM ACQUAINTANCE WHERE ACQUAINTANCE_UID = ?;");
    $stmnt2->bind_param('s', $username);
    $stmnt2->execute();
    $stmnt2->store_result();
    $amount = $stmnt2->num_rows;
    if ($amount >= 1) {
        echo "Acquaintance already exists ";
        return false;
    }
    $stmnt2->close();
    $stmnt = $conn->prepare("INSERT INTO ACQUAINTANCE(ACQUAINTANCE_UID, ACQUAINTANCE_FNAME, ACQUAINTANCE_LNAME, PICTURE_SET) VALUES(?,?,?,'/SECS/home/s/scnolton/facePics/{$username}')");
    $stmnt->bind_param('sss', $username, $fname, $lname);
    $stmnt->execute();
    $stmnt->close();
    $conn->close();
    return true;
}
开发者ID:Alzheimers480,项目名称:server,代码行数:28,代码来源:newacqu.php

示例5: deleteAcqu

function deleteAcqu($acquId)
{
    if (empty($acquId)) {
        //empty username and password
        echo "Acquaintance Not Found ";
        return false;
    }
    $conn = connectToDB();
    if (!$conn) {
        echo "conn failure ";
        return false;
    }
    $stmnt3 = $conn->prepare("SELECT * FROM ACQUAINTANCE WHERE ACQUAINTANCE_UID = ?;");
    $stmnt3->bind_param('s', $aacquId);
    $stmnt3->execute();
    $stmnt3->store_result();
    $amount = $stmnt3->num_rows;
    if ($amount == 0) {
        echo "Acquaintance does not exist ";
        return false;
    }
    $stmnt3->close();
    $stmnt = $conn->prepare("DELETE FROM RELATIONSHIP WHERE ACQUAINTANCE_UID = ?;");
    $stmnt->bind_param('s', $acquId);
    $stmnt->execute();
    $stmnt->close();
    $stmnt2 = $conn->prepare("DELETE FROM ACQUAINTANCE WHERE ACQUAINTANCE_UID = ?;");
    $stmnt2->bind_param('s', $acquId);
    $stmnt2->execute();
    $stmnt2->close();
    $conn->close();
    $dir = "/var/www/html/facePics/" . $acquId;
    exec("rm -r {$dir}");
    return true;
}
开发者ID:Alzheimers480,项目名称:docker,代码行数:35,代码来源:deleteacqu.php

示例6: printAllFunds

function printAllFunds()
{
    $conn = connectToDB();
    $sql = "SELECT * FROM ListOfFunds";
    $result = $conn->query($sql);
    echo "<table>";
    echo "<tr><th>Users</th><th>Fund Name</th><th>Activity</th><th>Fund</th><th>Function</th><th>Cost Center</th> <th>Project Code</th> <th>Balance</th> <th>As of</th> <th> Active </th></tr>";
    if ($result->num_rows > 0) {
        // Output data of each row
        while ($row = $result->fetch_assoc()) {
            echo "<tr><td><a href=\".\\funds.php?type=FID&FID=" . $row["FID"] . "\">" . $row["Users"] . "</a></td><td>" . $row["FundName"] . "</td><td>" . $row["Activity"] . "</td>";
            echo "<td>" . $row["Fund"] . "</td>";
            echo "<td>" . $row["Function"] . "</td>";
            echo "<td>" . $row["CostCenter"] . "</td>";
            echo "<td>" . $row["ProjectCode"] . "</td>";
            echo "<td>" . $row["Balance"] . "</td>";
            echo "<td>" . $row["BalanceAsOf"] . "</td>";
            if ($row["Active"] == 1) {
                echo "<td>" . "Yes" . "</td>";
            } else {
                echo "<td>" . "No" . "</td>";
            }
        }
    } else {
        echo "0 results in Funds";
    }
    $conn->close();
}
开发者ID:badavis,项目名称:pinkies,代码行数:28,代码来源:funds.php

示例7: newUser

function newUser($username, $password, $password2, $fname, $lname, $email)
{
    if (empty($username) || empty($password) || empty($password2) || empty($fname) || empty($lname) || empty($email)) {
        echo "one of the fields was blank ";
        return false;
    }
    if ($password != $password2) {
        echo "The 2 passwords didn't match ";
        return false;
    }
    $conn = connectToDB();
    if (!$conn) {
        echo "conn failure ";
        return false;
    }
    $stmnt2 = $conn->prepare("SELECT * FROM USERS2 WHERE USER_UID = ?;");
    $stmnt2->bind_param('s', $username);
    $stmnt2->execute();
    $stmnt2->store_result();
    $amount = $stmnt2->num_rows;
    if ($amount >= 1) {
        echo "user already exists ";
        return false;
    }
    $stmnt2->close();
    $stmnt = $conn->prepare("INSERT INTO USERS2(USER_UID,USER_PWDHSH,USER_PWDSALT,USER_FNAME,USER_LNAME, USER_EMAIL, VERIFYED) VALUES(?,?,?,?,?,?,1)");
    $salt = file_get_contents('/dev/urandom', false, null, 0, 64);
    $options = array('salt' => $salt);
    $phash = crypt($password, $salt);
    $stmnt->bind_param('ssssss', $username, $phash, $salt, $fname, $lname, $email);
    $stmnt->execute();
    $stmnt->close();
    $conn->close();
    return true;
}
开发者ID:Alzheimers480,项目名称:docker,代码行数:35,代码来源:newuser.php

示例8: nm_ket

function nm_ket($kode)
{
    $link = connectToDB();
    $data = mysql_query("select ket_unit_kerja from tb_unitkerja where left(kdunit,3)='{$kode}'", $link);
    $rdata = mysql_fetch_array($data);
    $result = trim($rdata['ket_unit_kerja']);
    return $result;
}
开发者ID:abbeet,项目名称:server39,代码行数:8,代码来源:DBConn.php

示例9: toSafeString

function toSafeString($str)
{
    $mysqli = connectToDB();
    $str = $mysqli->real_escape_string($str);
    $mysqli->close();
    $str = htmlentities($str, ENT_QUOTES, "utf-8");
    $str = trim($str);
    return $str;
}
开发者ID:pooya-alen1990,项目名称:sampleTalent,代码行数:9,代码来源:functions.php

示例10: setTagPrmpt

function setTagPrmpt($category, $tag, $prompt)
{
    sanitizeIn($category);
    sanitizeIn($tag);
    sanitizeIn($prompt);
    $conn = connectToDB();
    $sql = "UPDATE `Tags` SET TEntryAdvice='" . $prompt . "' WHERE CName='" . $cat . "' AND TName='" . $tag . "'";
    CheckedQuery($sql, $conn);
    $conn->close();
}
开发者ID:ahmeteren1453,项目名称:Web-Portal-Project,代码行数:10,代码来源:SetTagsHelper.php

示例11: getData

 function getData()
 {
     if (!$this->isLoggedIn()) {
         return NULL;
     }
     $conn = connectToDB();
     $user = GetSingleDbValue("SELECT * FROM `Users` WHERE `UserID`='" . $this->userID . "'", $conn);
     $conn->close();
     return $user;
 }
开发者ID:ahmeteren1453,项目名称:Web-Portal-Project,代码行数:10,代码来源:LoginHelper.php

示例12: checklogin

function checklogin($name, $passwd)
{
    $dbc = connectToDB("jed");
    $encodepw = sha1($passwd);
    $result = performQuery($dbc, "select * FROM pwdemo where name='{$name}' and pass='{$encodepw}'");
    $matches = mysqli_num_rows($result);
    mysqli_free_result($result);
    disconnectFromDB($dbc);
    return $matches == 1;
}
开发者ID:lowriek,项目名称:CSCI1154_Examples,代码行数:10,代码来源:loginCookie.php

示例13: sanitizeIn

function sanitizeIn(&$data)
{
    //Sanitizes a string for safe insertion into a mysqli query
    $conn = connectToDB();
    $data = mysqli_real_escape_string($conn, $data);
    $conn->close();
    //The previous function supposedly misses % and _ which do have special meaning for LIKE clauses, so escape those manually
    $data = addcslashes($data, '%_');
    return $data;
}
开发者ID:ahmeteren1453,项目名称:Web-Portal-Project,代码行数:10,代码来源:Sanitize.php

示例14: update_page_content_db

function update_page_content_db($page_name, $content, $uid)
{
    $con = connectToDB();
    if ($con) {
        $sql = "UPDATE `pagecontent` SET \n\t\t\t\t`pagecontent`='{$content}',\n\t\t\t\t`adminid`={$uid},\n\t\t\t\t`editeddate` = NOW( )\n\t\t\t\tWHERE `pagename`='{$page_name}';";
        $result = desql($sql);
        breakCon($con);
    }
    return $result;
}
开发者ID:googlecode-mirror,项目名称:tech-cs-ondemand,代码行数:10,代码来源:DatabaseController_waterski.ini.php

示例15: predict

function predict($file, $user)
{
    $guess = exec("/var/www/facerec/faces predict " . $file . " " . $user, $output);
    $guess = $output[0];
    $conn = connectToDB();
    $sql = "SELECT ACQUAINTANCE_FNAME, ACQUAINTANCE_LNAME, GENDER, RELATION, DESCRIPTION, ACQUAINTANCE_UID FROM RELATIONSHIP NATURAL JOIN ACQUAINTANCE WHERE USER_UID = '" . $user . "' AND REL_ID=" . $guess . ";";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    $row["DISTANCE"] = $output[1];
    echo json_encode($row);
}
开发者ID:Alzheimers480,项目名称:docker,代码行数:11,代码来源:predict.php


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