I have checked my syntax and it is correct, but there is still something missing; for when I call on the script using:
Code: Select all
<form action='/weather.php' method='get'><br>
<input type='submit' name='submit' value='Check'><br>
</form>Here is my script:
Code: Select all
<?php
function getWeather() {
$ip = $_SERVER['REMOTE_ADDR'];
$geo = shell_exec("/usr/bin/curl -s api.hostip.info/get_html.php?ip=$ip | /usr/bin/sed -e '1d;3d' -e's/C.*: \(.*\)/\1/' -e's|-|%2d|' -e's/ /%20/' -e\s/'/%27/'");
$getAddress = "http://www.google.com/ig/api?weather=$geo";
$xml_str = file_get_contents($getAddress,0);
$xml = new SimplexmlElement($xml_str);
$count = 0;
echo '<div id="weather">';
foreach($xml->weather as $item) {
foreach($item->current_conditions as $new) {
echo '<div class="weatherIcon">';
echo '<img src="http://www.google.com/' .$new->icon['data'] . '"/><br/>';
echo $new->condition['data'];
echo $new->temp_f['data'];
echo $new->temp_c['data'];
echo $new->humidity['data'];
echo $new->wind_condition['data'];
echo '</div>';
}
foreach($item->forecast_conditions as $new) {
echo '<div class="weatherIcon">';
echo '<img src="http://www.google.com/' .$new->icon['data'] . '"/><br/>';
echo $new->day_of_week['data'];
echo $new->condition['data'];
echo $new->low['data'];
echo $new->high['data'];
echo '</div>';
}
}
echo '</div>';
}
getWeather();
?>