2016-11-25 36 views
0

您好,我正在嘗試設置一個遊戲投注網站。我使用openId將數據從蒸汽傳輸到我的網站。但是這個「bug」發生在前一陣子。我無法爲每個連接的新用戶編寫新行。它在2天前工作。我不認爲我改變了任何東西,但它不起作用,所以必須改變。我的代碼很長,所以我只會發布我認爲有問題的部分。 所以它就是這樣。正如我所說,它應該爲新用戶編寫新行。PHP,openId - 無法寫入mysql

 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。

+1

究竟是什麼問題?你可以在更多的上下文中編輯,以及可能的PHP服務器錯誤日誌? –

+0

它不會引發任何錯誤。等待讓我檢查php錯誤日誌 –

+0

我檢查錯誤日誌,沒有錯誤。我真的不知道發生了什麼事。 –

回答

0

好的問題是我在表格中添加了新的必填列。感謝馬特克拉克的努力!