PHP、openId - 无法写入 mysql
PHP, openId - Can not write into mysql
您好,我正在尝试建立一个游戏博彩网站。我使用 openId 将数据从 Steam 传输到我的网站。但是这个 "bug" 发生在很久以前。我无法为每个连接的新用户写新行。它在 2 天前工作。我认为我没有改变任何东西,但它不起作用,所以必须改变一些东西。我的代码很长,所以我只 post 我认为有问题的部分。
所以就在这里。正如我所说,它应该为新用户写新行。
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;
}
}
编辑:我忘了说它没有显示任何错误或任何东西。它只是没有反应并且表现得像它通过了。例如会话索引是在玩家登录后设置的。它只是不写入 mysql.
好的,问题是我在 table 中添加了新的必填列。感谢马特·克拉克的努力!
您好,我正在尝试建立一个游戏博彩网站。我使用 openId 将数据从 Steam 传输到我的网站。但是这个 "bug" 发生在很久以前。我无法为每个连接的新用户写新行。它在 2 天前工作。我认为我没有改变任何东西,但它不起作用,所以必须改变一些东西。我的代码很长,所以我只 post 我认为有问题的部分。 所以就在这里。正如我所说,它应该为新用户写新行。
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;
}
}
编辑:我忘了说它没有显示任何错误或任何东西。它只是没有反应并且表现得像它通过了。例如会话索引是在玩家登录后设置的。它只是不写入 mysql.
好的,问题是我在 table 中添加了新的必填列。感谢马特·克拉克的努力!