PHP,openId - 无法写入mysql

标签 php html mysql openid steam

您好,我正在尝试建立一个游戏投注网站。我使用 openId 将数据从 steam 传输到我的网站。但这个“bug”是不久前发生的。我无法为每个连接的新用户写入新行。 2天前还在工作。我不认为我改变了任何东西,但它不起作用,所以必须改变一些东西。我的代码很长,所以我只会发布我认为有问题的部分。 所以就是这样。正如我所说,它应该为新用户写入新行。

        if($openid->validate()) 
    {
            $id = $openid->identity;
            // identity is something like: http://steamcommunity.com/openid/id/76561197960435530
            // we only care about the unique account ID at the end of the URL.
            $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
            preg_match($ptn, $id, $matches);
            echo "Sucesfully logged in (steamID: $matches[1])\n";

            $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=$matches[1]";
            $json_object= file_get_contents($url);
            $json_decoded = json_decode($json_object);

            foreach ($json_decoded->response->players as $player)
            {
                $sql_fetch_id = "SELECT * FROM users_steam WHERE steamid = $player->steamid";
                $query_id = mysqli_query($conn,$sql_fetch_id);

                if(mysqli_num_rows($query_id)==0){
                    $sql_steam = "INSERT INTO users_steam (name, steamid, avatar, loggedin, tradeurl) VALUES ('$player->personaname', '$player->steamid', '$player->avatar',' ',' ')";
                    mysqli_query($conn,$sql_steam);}

                $_SESSION["id"] = $player->steamid;
                $_SESSION["name"] = $player->personaname;
                $_SESSION["url"] = $player->profileurl;
                $_SESSION["smallavatar"] = $player->avatar;
                $_SESSION["mediumavatar"] = $player->avatarmedium;
                $_SESSION["largeavatar"] = $player->avatarfull;
            }
    } 

编辑:我忘了提及它没有显示任何错误或任何内容。它只是没有反应,表现得就像过去了一样。例如, session 索引是在玩家登录后设置的。它只是不写入mysql。

最佳答案

好吧,问题是我在表中添加了新的必需列。感谢马特·克拉克的努力!

关于PHP,openId - 无法写入mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40812851/

相关文章:

php - PHP 'and' 运算符的奇怪行为

php - 如何使用phpmyadmin构建数据库图表?

javascript - 在 html 中使用 javascript 展开/折叠不起作用

javascript - 如何将按钮作为html添加到div并添加点击功能

c# - 如何从 c# .net 中的单列数据中选择多个复选框

php - MySQL/PHP : How to calculate the average of a certain column using a JOIN statement

php - 使用循环仅显示每个 DISTINCT 字段值一次

php - 我无法在循环之外获取查询的值

javascript - 在页面 anchor 滚动和偏移标题

php - 如何获取/打印对我的 Twig 模板 (Drupal 8) 的实体引用的路径或 url?