Jump to content

enable to fix the errors could someone have a look


$php_mysql$

Recommended Posts

here is the code i edited

 

 

<html>    <head>        <title>API</title>    </head>    <body><?php$xml = simplexml_load_file('http://www.google.com/ig/api?weather=jakarta');$information = $xml->xpath("/xml_api_reply/weather/forecast_information");$current = $xml->xpath("/xml_api_reply/weather/current_conditions");$forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");        echo "<h1>print $information[0]->city['data']; </h1>";        echo "<h2>Today's weather</h2>";        echo "<div class=\"weather\">";		        echo "<img src=\"http://www.google.com' . $current[0]->icon['data']\" alt=\"weather\">";        echo "<span class=\"condition\">";        echo "$current[0]->temp_f['data'] ° F,";        echo "$current[0]->condition['data']";        echo "</span>";        echo "</div>";        echo "<h2>Forecast</h2>";        echo "foreach ($forecast_list as $forecast) :";        echo "<div class=\"weather\">";        echo "<img src=\"http://www.google.com' . $forecast->icon['data']\" alt=\"weather\">";        echo "<div>$forecast->day_of_week['data'];</div>";        echo "<span class=\"condition\">";echo "$forecast->low['data'] ?>° F - $forecast->high['data'] ° F,";echo "$forecast->condition['data'] ";        echo "</span>";        echo "</div>";?>	       <?endforeach?>    </body></html>

 

 

and here is the original

 

 

<?$xml = simplexml_load_file('http://www.google.com/ig/api?weather=jakarta');$information = $xml->xpath("/xml_api_reply/weather/forecast_information");$current = $xml->xpath("/xml_api_reply/weather/current_conditions");$forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");?><html>    <head>        <title>Google Weather API</title>    </head>    <body>        <h1><?= print $information[0]->city['data']; ?></h1>        <h2>Today's weather</h2>        <div class="weather">		            <img src="<?= 'http://www.google.com' . $current[0]->icon['data']?>" alt="weather"?>            <span class="condition">            <?= $current[0]->temp_f['data'] ?>° F,            <?= $current[0]->condition['data'] ?>            </span>        </div>        <h2>Forecast</h2>        <? foreach ($forecast_list as $forecast) : ?>        <div class="weather">            <img src="<?= 'http://www.google.com' . $forecast->icon['data']?>" alt="weather"?>            <div><?= $forecast->day_of_week['data']; ?></div>            <span class="condition">            <?= $forecast->low['data'] ?>° F - <?= $forecast->high['data'] ?>° F,            <?= $forecast->condition['data'] ?>            </span>        </div>	        <? endforeach ?>    </body></html>

 

 

the errors are

 

print ->city['data'];

Today's weather

weather->temp_f['data'] ° F,->condition['data']

Forecast

 

Notice: Undefined variable: forecast in C:\wamp\www\fiunc\test.php on line 24

foreach (Array as ) :

 

Notice: Undefined variable: forecast in C:\wamp\www\fiunc\test.php on line 26

 

Notice: Trying to get property of non-object in C:\wamp\www\fiunc\test.php on line 26

weather

Notice: Undefined variable: forecast in C:\wamp\www\fiunc\test.php on line 27

 

Notice: Trying to get property of non-object in C:\wamp\www\fiunc\test.php on line 27

['data'];

 

Notice: Undefined variable: forecast in C:\wamp\www\fiunc\test.php on line 29

 

Notice: Trying to get property of non-object in C:\wamp\www\fiunc\test.php on line 29

 

Notice: Undefined variable: forecast in C:\wamp\www\fiunc\test.php on line 29

 

Notice: Trying to get property of non-object in C:\wamp\www\fiunc\test.php on line 29

['data'] ?>° F - ['data'] ° F,

Notice: Undefined variable: forecast in C:\wamp\www\fiunc\test.php on line 30

 

Notice: Trying to get property of non-object in C:\wamp\www\fiunc\test.php on line 30

['data']

Link to comment
Share on other sites

did that now it looks like this

 

<html>
    <head>
        <title>API</title>
    </head>
    <body>

<?php
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=jakarta');
$information = $xml->xpath("/xml_api_reply/weather/forecast_information");
$current = $xml->xpath("/xml_api_reply/weather/current_conditions");
$forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");


        echo "<h1>print $information[0]->city['data']; </h1>";
        echo "<h2>Today's weather</h2>";
        echo "<div class=\"weather\">";      
        echo "<img src=\"http://www.google.com' . $current[0]->icon['data']\" alt=\"weather\">";
        echo "<span class=\"condition\">";
        echo "$current[0]->temp_f['data'] ° F,";
        echo "$current[0]->condition['data']";
        echo "</span>";
        echo "</div>";
        echo "<h2>Forecast</h2>";
        foreach ($forecast_list as $forecast) :
        echo "<div class=\"weather\">";
        echo "<img src=\"http://www.google.com' . $forecast->icon['data']\" alt=\"weather\">";
        echo "<div>$forecast->day_of_week['data'];</div>";
        echo "<span class=\"condition\">";
   echo "$forecast->low['data'] ?>° F - $forecast->high['data'] ° F,";
  echo "$forecast->condition['data'] ";
        echo "</span>";
        echo "</div>";
endforeach
?>   
      

    </body>
</html>

 

when i run it all i see in the screen is this

 

print ->city['data'];

Today's weather

weather->temp_f['data'] ° F,->condition['data']

Forecast

weather

['data'];

['data'] ?>° F - ['data'] ° F,['data']

weather

['data'];

['data'] ?>° F - ['data'] ° F,['data']

weather

['data'];

['data'] ?>° F - ['data'] ° F,['data']

weather

['data'];

['data'] ?>° F - ['data'] ° F,['data']

 

Link to comment
Share on other sites

USE PROPER STRING coNCATANATION

<html>
    <head>
        <title>API</title>
    </head>
    <body>

<?php
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=jakarta');
$information = $xml->xpath("/xml_api_reply/weather/forecast_information");
$current = $xml->xpath("/xml_api_reply/weather/current_conditions");
$forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");

        echo "<h1>".$information[0]->city['data']."</h1>";
        echo "<h2>Today's weather</h2>";
        echo "<div class=\"weather\">";      
        echo "<img src=\"http://www.google.com' . $current[0]->icon['data']\" alt=\"weather\">";
        echo "<span class=\"condition\">";
        echo $current[0]->temp_f['data']." ° F,";
        echo $current[0]->condition['data'];
        echo "</span>";
        echo "</div>";
        echo "<h2>Forecast</h2>";
        foreach ($forecast_list as $forecast) :
        echo "<div class=\"weather\">";
        echo "<img src=\"http://www.google.com' . $forecast->icon['data']\" alt=\"weather\">";
        echo "<div>".$forecast->day_of_week['data']."</div>";
        echo "<span class=\"condition\">";
    echo  $forecast->low['data']."° F - ".$forecast->high['data']."° F,";
    echo $forecast->condition['data'] ;
        echo "</span>";
        echo "</div>";
?>   
       <?php endforeach ?>

    </body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.