當前位置: 首頁>>代碼示例>>PHP>>正文


PHP dbex::real_escape_string方法代碼示例

本文整理匯總了PHP中dbex::real_escape_string方法的典型用法代碼示例。如果您正苦於以下問題:PHP dbex::real_escape_string方法的具體用法?PHP dbex::real_escape_string怎麽用?PHP dbex::real_escape_string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dbex的用法示例。


在下文中一共展示了dbex::real_escape_string方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: task

 // 扣錢成功,寫task表
 $sql = "insert into task (owner_id, publisher_id, type, base_price, amount, status, create_at, expire_in) values('{$_SESSION['uid']}', '{$_SESSION['uid']}', 1, '{$db_base_price}', '{$amount}', 1, now(), '{$expire_in_sec}')";
 $num = $dbo->exeUpdate($sql);
 if (1 != $num) {
     // 寫數據表失敗,回滾金錢數據
     $sql2 = "update user set realtime_money=realtime_money + {$db_total_price} where user_id = '{$_SESSION['uid']}' limit 1";
     $num2 = $dbo->exeUpdate($sql2);
     if (1 != $num2) {
         $msg = "回滾金錢數據失敗,這個比較糟糕。SQL:" . $sql2;
         debug($msg, __FILE__, __LINE__);
     }
     $msg = '數據庫task表插入出錯,SQL:' . $sql;
     debug($msg, __FILE__, __LINE__);
 }
 $last_task_id = $dbo->lastInsertId();
 $text = $dbo->real_escape_string($status['text']);
 $screen_name = $dbo->real_escape_string($status['user']['screen_name']);
 $location = $dbo->real_escape_string($status['user']['location']);
 $description = $dbo->real_escape_string($status['user']['description']);
 $sql = "insert into task_info_sina_repost values(NULL, '{$last_task_id}', '{$_SESSION['sid']}', '{$wid}', '{$text}', '{$screen_name}', '{$location}', '{$description}', '{$status['user']['profile_image_url']}', '{$status['thumbnail_pic_url']}', '{$status['bmiddle_pic_url']}', '{$status['original_pic_url']}')";
 $num = $dbo->exeUpdate($sql);
 if (1 != $num) {
     $msg = '數據庫插入數據出錯。SQL:' . $sql;
     debug($msg, __FILE__, __LINE__);
     // 回滾金錢數據和task表數據
     $sql1 = "delete from task where task_id = '{$last_task_id}' limit 1";
     $num1 = $dbo->exeUpdate($sql1);
     $sql2 = "update user set realtime_money = realtime_money + {$db_total_price} where user_id = '{$_SESSION['uid']}' limit 1";
     $num2 = $dbo->exeUpdate($sql2);
     if (1 != $num1) {
         $msg = "回滾金錢數據失敗,這個比較糟糕。SQL:" . $sql1;
開發者ID:mafergomez70,項目名稱:micro-power,代碼行數:31,代碼來源:create_task.php

示例2: header

        echo '對不起,該注冊鏈接已經失效。<a href="' . $siteRoot . 'pre_reg.php">點此重新獲取</a>注冊鏈接,或<a href="' . $siteRoot . 'index.php">點此登錄</a>。';
        $dbo->close();
        exit;
    }
} else {
    // 沒有帶token和email
    header('Location:' . $siteRoot . 'pre_reg.php');
    $dbo->close();
    exit;
}
// token和email有效
if (isset($_POST['submitted'])) {
    // 當前頁麵已提交,現在處理提交的數據
    $dbo = new dbex($dbServs);
    $err_msg = array();
    $e = $dbo->real_escape_string($email);
    $n = trim($_POST['name']);
    if (check_nickname_fail($n)) {
        $err_msg[] = "請填寫符合規定的用戶昵稱";
    } else {
        if ($dbo->checkExist($n, 'nick_name')) {
            $err_msg[] = "這個昵稱太熱門,已經被使用了,您換一個試試";
        }
    }
    $n = $dbo->real_escape_string($n);
    $p1 = trim($_POST['pass1']);
    $p2 = trim($_POST['pass2']);
    if (check_password_fail($p1)) {
        $err_msg[] = "請設置符合規定的密碼";
    } else {
        if ($p1 !== $p2) {
開發者ID:mafergomez70,項目名稱:micro-power,代碼行數:31,代碼來源:reg.php

示例3: header

    header('Location:' . $siteRoot . 'my.php');
    exit;
}
// 尚未登錄,進行登錄
if (isset($_POST['submitted']) && isset($_POST['email']) && isset($_POST['pass'])) {
    $e = trim($_POST['email']);
    $p = trim($_POST['pass']);
    if (check_email_fail($e) || check_password_fail($p)) {
        // 郵箱或密碼格式不對
        header('Location:' . $siteRoot . 'index.php?login_error=wrong_format');
        exit;
    }
    include_once $webRoot . "lib/dbo.class.php";
    include_once $dbConfFile;
    $dbo = new dbex($dbServs);
    $e = $dbo->real_escape_string($e);
    $ency_p = md5($p);
    $sql = "select user_id, nick_name, role, level, realtime_money from user where email = '{$e}' and pass = sha1('{$ency_p}') limit 1";
    $res = $dbo->query($sql);
    if (1 != $res->num_rows) {
        // 郵箱與密碼不匹配
        header('Location:' . $siteRoot . 'index.php?login_error=mismatch');
        exit;
    }
    // 登錄成功
    $row = $res->fetch_array();
    $_SESSION['uid'] = $row['user_id'];
    $_SESSION['name'] = $row['nick_name'];
    $_SESSION['role'] = user_role_switch($row['role'], false);
    // from num to string
    $_SESSION['level'] = $row['level'];
開發者ID:mafergomez70,項目名稱:micro-power,代碼行數:31,代碼來源:v_login.php


注:本文中的dbex::real_escape_string方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。