I am trying to get my code to work when the url its sent to does not have the variables needed.
this is the error:
E_WARNING : type 2 -- file_get_contents(the link): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found -- at line 23
Ex my code goes to this users page and everything okay:
But when it goes to this users page it gives a error:
What im after doing if when there is no content in url for it not to show anything and when there is to show it. But for some reason I cant get it to work with both.
Here is my code:
<?php
$apiKey = 'APIKEY';
$summonerName = 'raget deathdex';
$new = rawurlencode($summonerName);
$news = str_replace(' ', '', $summonerName);
$str = strtolower($news);
$result = file_get_contents('https://euw.api.pvp.net/api/lol/euw/v1.4/summoner/by-name/' . $new . '?api_key=' . $apiKey);
$summoner = json_decode($result)->$str;
$id = $summoner->id;
?>  
<?php   
$claw = file_get_contents('https://euw.api.pvp.net/api/lol/euw/v1.3/stats/by-summoner/' . $id . '/ranked?season=SEASON2016&api_key=' . $apiKey);
$gaza = json_decode($claw);
?>
<?php 
$entriesz = $gaza->champions;
usort($entriesz, function($ac,$bc){
    return $bc->stats->totalSessionsPlayed-$ac->stats->totalSessionsPlayed;
});
foreach($entriesz as $statSummaryz) if ($tmp++ < 11){
    $getLeagueNamelistside = $statSummaryz->id;
    $getsessionsplayedNamelistside = $statSummaryz->stats->totalSessionsPlayed;
    $getMiniomskillsNamelistside = $statSummaryz->stats->totalMinionKills;
    $getkillsNamelistside = $statSummaryz->stats->totalChampionKills;
    $getassistssNamelistside = $statSummaryz->stats->totalAssists;
    $getdeathsNamelistside = $statSummaryz->stats->totalDeathsPerSession;
    $getlosseslistside = $statSummaryz->stats->totalSessionsLost;
    $getwinslistside = $statSummaryz->stats->totalSessionsWon;
    $Percentkillrateside = $getkillsNamelistside / $getsessionsplayedNamelistside;
    $Percentassistrateside = $getassistssNamelistside / $getsessionsplayedNamelistside;
    $Percentdeathrateside = $getdeathsNamelistside / $getsessionsplayedNamelistside;
    $KDAside = ($getkillsNamelistside + $getassistssNamelistside) / $getdeathsNamelistside;
    $KDAMinniomsSide = $getMiniomskillsNamelistside / $getsessionsplayedNamelistside;
    $PercentWinRateSide = 100 / ($getlosseslistside + $getwinslistside) * $getwinslistside;
    if ($getLeagueNamelistside >=1){
        $resultz = file_get_contents('https://global.api.pvp.net/api/lol/static-data/euw/v1.2/champion/'.$getLeagueNamelistside.'?api_key=' . $apiKey);
        $summonerz = json_decode($resultz, true);
        $getLeagueNamelistsidez = $summonerz['name'];
        $getLeagueKeyNamelistsidez = $summonerz['key'];
        echo '<p><img src="http://lolchecker.esy.es/LOLGGWP/img/champion/' .$getLeagueKeyNamelistsidez. '.png"></p>'.$getLeagueNamelistsidez. '<p> Kills '.number_format((float)$Percentkillrateside, 1, '.', '').'</p><p> Deaths '.number_format((float)$Percentdeathrateside, 1, '.', '').'</p><p> Assists '.number_format((float)$Percentassistrateside, 1, '.', '').'</p><p> KDA '.number_format((float)$KDAside, 2, '.', '').':1 KDA</p><p> CS '.number_format((float)$KDAMinniomsSide, 1, '.', '').' CS</p><p> Games Played '.$getsessionsplayedNamelistside.'</p><p> Win Rate '.number_format((float)$PercentWinRateSide, 0, '.', '').'%</p>';
    }
    elseif($getLeagueNamelistside =0){
        return DO_NOTHING;
    }
}
?>
 
     
     
     
    