PHP isset get issue error in else statement -
this question has answer here:
- php parse/syntax errors; , how solve them? 12 answers
i trying index.php?steamusr=username get's set var , if none specified displays error specified in else statement.
i have tried if empty , isset. have been trying every combo can find , still nothing. current code, bottom 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'] $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 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
the else
part works first conditional statement, therefore needs placed after last brace.
<?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'] $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 here before } else { echo '<h1>no steam user set</h2>'; } ?>
Comments
Post a Comment