MYSQL错误,我做错了什么?

时间:2015-07-24 16:32:19

标签: mysql steam

如果我从下面的代码中删除or die("MySQL ERROR: ".mysqli_error());,则不会给我任何错误。但它也没有写入数据库。

我做错了什么?

ob_start();
session_start();
require ('openid.php');

function logoutbutton() {
    echo "<form action=\"steamauth/logout.php\" method=\"post\"><input value=\"Logout\" type=\"submit\" /></form>"; //logout button
}

function steamlogin() {
    try {
        require("steamauth/settings.php");
        $openid = new LightOpenID($steamauth['domainname']);

        $button['small'] = "small";
        $button['large_no'] = "large_noborder";
        $button['large'] = "large_border";
        $button = $button[$steamauth['buttonstyle']];

        if(!$openid->mode) {
            if(isset($_GET['login'])) {
                $openid->identity = 'http://steamcommunity.com/openid';
                header('Location: ' . $openid->authUrl());
            }
            //echo "<form action=\"?login\" method=\"post\"> <input type=\"image\" src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_".$button.".png\"></form>";
        } elseif($openid->mode == 'cancel') {
            echo 'User has canceled authentication!';
        } else {
            if($openid->validate()) { 
                $id = $openid->identity;
                $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
                preg_match($ptn, $id, $matches);

                $_SESSION['steamid'] = $matches[1]; 
                include_once("set.php");
                $query = mysqli_query("SELECT * FROM users WHERE steamid='".$_SESSION['steamid']."'");
                if (mysqli_num_rows($query) == 0) {
                    mysqli_query("INSERT INTO users (steamid) VALUES ('".$_SESSION['steamid']."')") or die("MySQL ERROR: ".mysqli_error());
                }
                if (isset($steamauth['loginpage'])) {
                    header('Location: '.$steamauth['loginpage']);
                }
            } else {
                echo "User is not logged in.\n";
            }
        }
    } catch(ErrorException $e) {
        echo $e->getMessage();
    }
}

这是我的数据库结构的屏幕截图:

my database structure

0 个答案:

没有答案