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


PHP mysqli_stmt_close函数代码示例

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


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

示例1: authenticate_user

function authenticate_user($data)
{
    global $db;
    $email = $data['email'];
    $password = $data['password'];
    //getting the salt
    $stmt = mysqli_prepare($db, "SELECT salt FROM users WHERE email = ? LIMIT 1");
    mysqli_stmt_bind_param($stmt, "s", $email);
    mysqli_stmt_execute($stmt);
    mysqli_stmt_store_result($stmt);
    mysqli_stmt_bind_result($stmt, $salt);
    if (mysqli_stmt_num_rows($stmt)) {
        mysqli_stmt_fetch($stmt);
        $password = hash('sha256', "{$password}" . "{$salt}");
        //adding salt to given pass hashing and checking if the resulting hash is the same as the original
        mysqli_stmt_close($stmt);
        $stmt = mysqli_prepare($db, "SELECT uid, username, email FROM users WHERE email = ? AND password = ?");
        mysqli_stmt_bind_param($stmt, "ss", $email, $password);
        mysqli_stmt_execute($stmt);
        mysqli_stmt_store_result($stmt);
        mysqli_stmt_bind_result($stmt, $uid, $username, $email);
        if (mysqli_stmt_num_rows($stmt)) {
            mysqli_stmt_fetch($stmt);
            mysqli_stmt_close($stmt);
            $user = ['userid' => $uid, 'username' => $username, 'email' => $email];
            return $user;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
开发者ID:AlexandrosKal,项目名称:mylib,代码行数:33,代码来源:user_functions.php

示例2: get_makes

 public static function get_makes()
 {
     //open connection to MySql
     parent::open_connection();
     //initialize arrays
     $ids = array();
     //array for ids
     $list = array();
     //array for objects
     //query
     $query = "select mak_id from makes";
     //prepare command
     $command = parent::$connection->prepare($query);
     //execute command
     $command->execute();
     //link results
     $command->bind_result($id);
     //fill ids array
     while ($command->fetch()) {
         array_push($ids, $id);
     }
     //close command
     mysqli_stmt_close($command);
     //close connection
     parent::close_connection();
     //fill object array
     for ($i = 0; $i < count($ids); $i++) {
         array_push($list, new Make($ids[$i]));
     }
     //return array
     return $list;
 }
开发者ID:Jczamarripa,项目名称:cars2015,代码行数:32,代码来源:catalogs.php

示例3: saveAction

/**
 * Save data
 * @param   array   Request data (unfiltered)
 */
function saveAction($request)
{
    require_once 'config.php';
    //connection:
    $link = mysqli_connect($servidor, $user, $pass, $database) or die("Error " . mysqli_error($link));
    $flag = 'false';
    $param = $request;
    $idUrl = mysqli_real_escape_string($link, $param['idUrl']);
    $dataPost = isset($param['data']) ? $param['data'] : false;
    $idPage = _checkIdUrl($link, $idUrl);
    if ($idPage > 0 && is_array($dataPost) && count($dataPost) > 0) {
        $reg = formarDataToSerial($idPage, $dataPost);
        $reg['page_id'] = intval($reg['page_id']);
        $reg['browser_id'] = $reg['browser_id'];
        $reg['view_port'] = mysqli_real_escape_string($link, $reg['view_port']);
        $reg['window_browser'] = mysqli_real_escape_string($link, $reg['window_browser']);
        $reg['screen'] = mysqli_real_escape_string($link, $reg['screen']);
        $query = "INSERT INTO heatmap (page_id, browser_id, view_port, window_browser, screen, data_serial, created_at) " . "VALUES ('" . $reg['page_id'] . "', '" . $reg['browser_id'] . "','" . $reg['view_port'] . "','" . $reg['window_browser'] . "','" . $reg['screen'] . "', '" . $reg['data_serial'] . "', '" . date('Y-m-d H:i:s') . "')";
        $stmt = mysqli_prepare($link, $query);
        mysqli_stmt_execute($stmt);
        mysqli_stmt_close($stmt);
        $flag = 'true';
    }
    mysqli_close($link);
    echo $flag;
}
开发者ID:beeznest,项目名称:heatmap,代码行数:30,代码来源:controller.php

示例4: email

function email()
{
    global $link, $stmt;
    if (defined("CRYPT_BLOWFISH") && CRYPT_BLOWFISH) {
        $salt = '$2y$11$' . substr(md5(uniqid(rand(), true)), 0, 22);
        $password = crypt($_POST['password'], $salt);
    }
    mysqli_stmt_bind_param($stmt, 'ss', $_POST['email'], $password);
    mysqli_stmt_execute($stmt);
    mysqli_stmt_close($stmt);
    //to verify email
    $hash = hash('md5', $_POST["email"]);
    $stmt = mysqli_prepare($link, "INSERT INTO `verify_email`(`email`, `hash`) VALUES(?,'" . $hash . "')") or die(mysqli_error($link));
    mysqli_stmt_bind_param($stmt, 's', $_POST['email']);
    mysqli_stmt_execute($stmt);
    mysqli_stmt_close($stmt);
    mysqli_close($link);
    $to = $_POST['email'];
    $subject = 'Email varification';
    $message = 'Please click this link to activate your account: http://woofwarrior.com//gallery/verify.php?email=' . $_POST['email'] . '&hash=' . $hash . ' ';
    $headers = "From: activation@woofwarrior.com\r\n";
    mail($to, $subject, $message, $headers);
    //echo json_encode('signed up, verify email. Please click this link to activate your account: http://woofwarrior.com//gallery/htdocs/verify.php?email='.$_POST['email'].'&hash='.$hash);
    echo json_encode('verify email');
}
开发者ID:tinggao,项目名称:woofWarrior,代码行数:25,代码来源:signup.php

示例5: bindFetch

function bindFetch($stmt, $valArray)
{
    prepareStatment($stmt, $valArray);
    mysqli_stmt_execute($stmt);
    $array = array();
    if ($stmt instanceof mysqli_stmt) {
        $stmt->store_result();
        $variables = array();
        $data = array();
        $meta = $stmt->result_metadata();
        while ($field = $meta->fetch_field()) {
            $variables[] =& $data[$field->name];
        }
        // pass by reference
        call_user_func_array(array($stmt, 'bind_result'), $variables);
        $i = 0;
        while ($stmt->fetch()) {
            $array[$i] = array();
            foreach ($data as $k => $v) {
                $array[$i][$k] = $v;
            }
            $i++;
        }
    } elseif ($stmt instanceof mysqli_result) {
        while ($row = $stmt->fetch_assoc()) {
            $array[] = $row;
        }
    }
    mysqli_stmt_close($stmt);
    return $array;
}
开发者ID:NateThurmond,项目名称:MechDesign-php,代码行数:31,代码来源:sqlPrepare.php

示例6: registrator

function registrator($link)
{
    //Функция регистрации пользователя (Взято из интернета "редактированно")
    if (!empty($_POST["submit"])) {
        if (!preg_match("/^[a-zA-Z0-9]+\$/", $_POST['login'])) {
            $err[] = "Логин может состоять только из букв английского алфавита и цифр<br>";
        }
        if (strlen($_POST['login']) < 3 or strlen($_POST['login']) > 30) {
            $err[] = "Логин должен быть не меньше 3-х символов и не больше 30<br>";
        }
        $query = "SELECT COUNT(user_id) FROM users WHERE user_login='" . mysqli_real_escape_string($link, $_POST['login']) . "'";
        if ($stmt = mysqli_prepare($link, $query)) {
            mysqli_stmt_execute($stmt);
            mysqli_stmt_bind_result($stmt, $user_id);
            mysqli_stmt_store_result($stmt);
            mysqli_stmt_fetch($stmt);
            mysqli_stmt_close($stmt);
        }
        if (!$user_id == 0) {
            $err[] = "Пользователь с таким логином уже существует в базе данных<br>";
        }
        if (count($err) == 0) {
            $login = $_POST['login'];
            $password = md5(md5(trim($_POST['password'])));
            mysqli_query($link, "INSERT INTO users SET user_login='" . $login . "', user_password='" . $password . "'");
            header("Location: login.php");
            exit;
        } else {
            print "<b>При регистрации произошли следующие ошибки:</b><br>";
            foreach ($err as $error) {
                print $error . "<br>";
            }
        }
    }
}
开发者ID:Latinoz,项目名称:shop_catalog,代码行数:35,代码来源:lib.inc.php

示例7: update_last_try

function update_last_try($dbh, $config, $key)
{
    $stmt = mysqli_prepare($dbh, "UPDATE " . $config['table_prefix'] . "keys SET last_try = NOW() WHERE `key` = ?");
    mysqli_stmt_bind_param($stmt, "s", $key);
    mysqli_stmt_execute($stmt);
    mysqli_stmt_close($stmt);
}
开发者ID:basvdburg,项目名称:php-notify-telegram,代码行数:7,代码来源:functions.php

示例8: changeItem

function changeItem($elemID, $uniqueID, $changeTo)
{
    // Connect to the MySQL database
    $host = "fall-2015.cs.utexas.edu";
    $user = "pjobrien";
    $file = fopen("/u/pjobrien/password.txt", "r");
    $line = fgets($file);
    $pwd = trim($line);
    fclose($file);
    $dbs = "cs329e_pjobrien";
    $port = "3306";
    $connect = mysqli_connect($host, $user, $pwd, $dbs, $port);
    if (empty($connect)) {
        die("mysql_connect failed " . mysqli_connect_error());
    }
    $elemID = trim($elemID);
    $uniqueID = trim($uniqueID);
    $changeTo = trim($changeTo);
    // get the item we want to change from the front end
    $stmt = mysqli_prepare($connect, "UPDATE userInfo SET {$elemID} = ? WHERE username= ?");
    mysqli_stmt_bind_param($stmt, 'ss', $changeTo, $uniqueID) or die("Failed: " . mysqli_error($connect));
    mysqli_stmt_execute($stmt) or die("Failed: " . mysqli_error($connect));
    mysqli_stmt_close($stmt);
    // Close connection to the database
    mysqli_close($connect);
    return true;
}
开发者ID:pjobrien93,项目名称:Web-Programs,代码行数:27,代码来源:update.php

示例9: __construct

 function __construct()
 {
     if (func_num_args() == 0) {
         $this->id = '';
         $this->name = '';
         $this->description = '';
         $this->dosification = '';
         $this->peridiocity = "";
     }
     if (func_num_args() == 1) {
         $args = func_get_args();
         $id = $args[0];
         parent::open_connection();
         $query = "select schedule_id, schedule_name, schedule_note from Activities_Schedule where schedule_id = ?";
         $command = parent::$connection->prepare($query);
         $command->bind_param('s', $id);
         $command->execute();
         $command->bind_result($this->id, $this->name, $this->description);
         $found = $command->fetch();
         mysqli_stmt_close($command);
         parent::close_connection();
         if (!$found) {
             throw new RecordNotFoundException();
         }
     }
 }
开发者ID:HogiQuin,项目名称:CIALAC,代码行数:26,代码来源:activity.php

示例10: checkCredentials

function checkCredentials($username, $password)
{
    $link = retrieve_mysqli();
    //Test to see if their credentials are valid
    $queryString = 'SELECT salt, hashed_password FROM user WHERE username = ?';
    if ($stmt = mysqli_prepare($link, $queryString)) {
        //Get the stored salt and hash as $dbSalt and $dbHash
        mysqli_stmt_bind_param($stmt, "s", $username);
        mysqli_stmt_execute($stmt);
        mysqli_stmt_bind_result($stmt, $dbSalt, $dbHash);
        mysqli_stmt_fetch($stmt);
        mysqli_stmt_close($stmt);
        // close prepared statement
        mysqli_close($link);
        /* close connection */
        //Generate the local hash to compare against $dbHash
        $localhash = generateHash($dbSalt . $password);
        //Compare the local hash and the database hash to see if they're equal
        if ($localhash == $dbHash) {
            return true;
        }
        // password hashes matched, this is a valid user
    }
    return false;
    // password hashes did not match or username didn't exist
}
开发者ID:HomerGaidarski,项目名称:Gunter-Hans-Transaction-Reports,代码行数:26,代码来源:helper.php

示例11: update_vote

function update_vote($image_id)
{
    //get number of votes and update
    global $link;
    /*$result = mysqli_query($link, "SELECT `amount` FROM `votes_amount` WHERE `imageID`=".$image_id.";") or die(mysqli_error($link));
    	$amount = mysqli_fetch_assoc($result);
    	$new_amount = $amount['amount']+1;
    	mysqli_query($link, "UPDATE `votes_amount` SET `amount`=".$new_amount." WHERE `imageID`=".$image_id.";") or die(mysqli_error($link));*/
    $stmt = mysqli_stmt_init($link);
    mysqli_stmt_prepare($stmt, "SELECT `amount` FROM `votes_amount` WHERE `imageID`=?;") or die(mysqli_error($link));
    mysqli_stmt_bind_param($stmt, 'i', $image_id);
    mysqli_stmt_execute($stmt);
    $result = mysqli_stmt_get_result($stmt);
    mysqli_stmt_close($stmt);
    $amount = mysqli_fetch_assoc($result);
    $new_amount = $amount['amount'] + 1;
    $stmt = mysqli_prepare($link, "UPDATE `votes_amount` SET `amount`=" . $new_amount . " WHERE `imageID`=?;") or die(mysqli_error($link));
    mysqli_stmt_bind_param($stmt, 'i', $image_id);
    mysqli_stmt_execute($stmt);
    mysqli_stmt_close($stmt);
    //return ajax data
    if (isset($_SESSION['id']) && !isset($_POST['action']) && !isset($_POST['votePic'])) {
        $data = array('new_amount' => $new_amount, 'imageID' => $image_id);
    } elseif (isset($_POST['action']) && $_POST['action'] == 'anonymous_voting') {
        //get another two images
        $result = mysqli_query($link, "SELECT * FROM `image` ORDER BY RAND() LIMIT 2;") or die(mysqli_error($link));
        $data = array();
        while ($row = mysqli_fetch_assoc($result)) {
            $data[] = $row;
        }
    }
    mysqli_close($link);
    return $data;
}
开发者ID:tinggao,项目名称:woofWarrior,代码行数:34,代码来源:vote.php

示例12: getPageInfo

function getPageInfo($con, $page_id)
{
    $result_array = array();
    $query_case_list = "SELECT key_value_latin FROM page WHERE page_id = ?";
    if (!($stmt = mysqli_prepare($con, $query_case_list))) {
        #echo "Prepare failed: (" . mysqli_connect_errno() . ") " . mysqli_connect_error()."<br>";
    }
    //set values
    #echo "set value...";
    $id = 1;
    if (!mysqli_stmt_bind_param($stmt, "s", $page_id)) {
        #echo "Binding parameters failed: (" . mysqli_connect_errno() . ") " . mysqli_connect_error()."<br>";
    }
    #echo "execute...";
    if (!mysqli_stmt_execute($stmt)) {
        #echo "Execution failed: (" . mysqli_connect_errno() . ") " . mysqli_connect_error()."<br>";
    }
    /* instead of bind_result: */
    #echo "get result...";
    if (!mysqli_stmt_bind_result($stmt, $key_value_latin)) {
        #echo "Getting results failed: (" . mysqli_connect_errno() . ") " . mysqli_connect_error()."<br>";
    }
    if (mysqli_stmt_fetch($stmt)) {
        $result_array = array("key_value_latin" => $key_value_latin);
    } else {
        #echo "Fetching results failed: (" . mysqli_connect_errno() . ") " . mysqli_connect_error()."<br>";
        print_r(error_get_last());
    }
    mysqli_stmt_close($stmt);
    return $result_array;
}
开发者ID:VarenKoks,项目名称:fdt-page-scrapper,代码行数:31,代码来源:news_poster.php

示例13: EliminarRedSocial

 public function EliminarRedSocial($id)
 {
     $mysqli = $this->mysqli;
     $stmt = \mysqli_prepare($mysqli, "CALL ELIMINAR_RS(?)");
     \mysqli_stmt_bind_param($stmt, 'i', $id);
     \mysqli_stmt_execute($stmt);
     \mysqli_stmt_close($stmt);
 }
开发者ID:keua,项目名称:DeGuate,代码行数:8,代码来源:CL_REDSOCIAL.php

示例14: EliminarImagen

 public function EliminarImagen($imagen)
 {
     $mysqli = $this->mysqli;
     $stmt = \mysqli_prepare($mysqli, "CALL ELIMINAR_IMG(?);");
     \mysqli_stmt_bind_param($stmt, 'i', $imagen);
     \mysqli_stmt_execute($stmt);
     \mysqli_stmt_close($stmt);
 }
开发者ID:keua,项目名称:DeGuate,代码行数:8,代码来源:CL_IMAGEN.php

示例15: mysqli_fetch_array_large

function mysqli_fetch_array_large($offset, $link, $package_size)
{
    /* we are aiming for maximum compression to test MYSQLI_CLIENT_COMPRESS */
    $random_char = str_repeat('a', 255);
    $sql = "INSERT INTO test(label) VALUES ";
    while (strlen($sql) < $package_size - 259) {
        $sql .= sprintf("('%s'), ", $random_char);
    }
    $sql = substr($sql, 0, -2);
    $len = strlen($sql);
    assert($len < $package_size);
    if (!@mysqli_query($link, $sql)) {
        if (1153 == mysqli_errno($link) || 2006 == mysqli_errno($link) || stristr(mysqli_error($link), 'max_allowed_packet')) {
            /*
            	myslqnd - [1153] Got a packet bigger than 'max_allowed_packet' bytes
            	libmysql -[2006] MySQL server has gone away
            */
            return false;
        }
        printf("[%03d + 1] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    /* buffered result set - let's hope we do not run into PHP memory limit... */
    if (!($res = mysqli_query($link, "SELECT id, label FROM test"))) {
        printf("[%03d + 2] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    while ($row = mysqli_fetch_assoc($res)) {
        if ($row['label'] != $random_char) {
            printf("[%03d + 3] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n", $offset, $random_char, $row['label'], $len, mysqli_errno($link), mysqli_error($link));
            return false;
        }
    }
    mysqli_free_result($res);
    if (!($stmt = mysqli_prepare($link, "SELECT id, label FROM test"))) {
        printf("[%03d + 4] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    /* unbuffered result set */
    if (!mysqli_stmt_execute($stmt)) {
        printf("[%03d + 5] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
        return false;
    }
    $id = $label = NULL;
    if (!mysqli_stmt_bind_result($stmt, $id, $label)) {
        printf("[%03d + 6] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
        return false;
    }
    while (mysqli_stmt_fetch($stmt)) {
        if ($label != $random_char) {
            printf("[%03d + 7] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n", $offset, $random_char, $label, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
            return false;
        }
    }
    mysqli_stmt_free_result($stmt);
    mysqli_stmt_close($stmt);
    return true;
}
开发者ID:gleamingthecube,项目名称:php,代码行数:58,代码来源:ext_mysqli_tests_mysqli_fetch_array_large.php


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