I am trying to get it so index.php?steamusr=username get's set as the var and if none is specified it just displays a the error specified in the else statement.
I have tried if empty and isset. I have been trying every combo I can find and still nothing. This is my current code, the bottom is the error message. Thanks!
<?php
if (isset($_GET['steamusr'])) {
$user = $_GET['steamusr'];
$myinv = 'http://steamcommunity.com/id/$user/inventory/json/295110/1/';
$content2 = file_get_contents($myinv);
$json2 = json_decode($content2, true);
$imgurlbase = 'http://steamcommunity-a.akamaihd.net/economy/image/';
foreach($json2['rgDescriptions'] as $i){
$item = $i['market_name'];
$icon = $i['icon_url'];
$fetchdata = 'http://steamcommunity.com/market/priceoverview/?appid=295110¤cy=1&market_hash_name=' . urlencode($item);
$grab = file_get_contents($fetchdata);
$id = json_decode($grab, true);
echo '<img src="'. $imgurlbase . $icon . '/64fx64f">' . '<a class="btn btn-primary btn-lg" href="#" role="button">'.'<span class="badge">1</span> ' . $item .'</a>' . '<a class="btn btn-primary btn-lg" href="#" role="button">'.'Low</br>'. $id['lowest_price'].'</a>'.'<a class="btn btn-primary btn-lg" href="#" role="button">'.'Avg</br>'. $id['median_price'].'</a>'.'<br>';
}
else {
echo '<h1>No steam user set</h2>';
}
}
?>
Here is the error:
[Wed Aug 19 09:24:33.723604 2015] [:error] [pid 21378] [client 67.90.138.68:62702] PHP Parse error: syntax error, unexpected 'else' (T_ELSE) in /var/www/index.php on line 58
No steam user set'; }` after your last brace. That goes for `if (isset($_GET['steamusr'])) {`
– Funk Forty Niner Aug 19 '15 at 13:37