Welcome Guest, Not a member yet? Register   Sign In
"Notice" in my lib, xml trouble
#1

[eluser]Unknown[/eluser]
sorry for my bad(very bad) english

i have controller

Code:
<?php

class Main extends Controller {

    function Main()
    {
        parent::Controller();    
    }
    
    function index() {
              $this->load->library('weather');
              echo $this->weather->getWeather(1310);
    }
}
?>
and simple library
Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Weather {

    function Weather() {
        $this->CI =& get_instance();
    }

    public function getWeather($city) {
          $xmlstr = @join('',file('http://weather.co.ua/xml/feed.xml?version=1.1&city;='.intval($city).'&dayf=5'));
          $xml = new SimpleXMLElement($xmlstr);
      
          for($i=0;$i<24;$i++) {
            $xmlpath = $xml->forecast->day[$i];
            $cloud = $xmlpath->cloud;
            $pict = $xmlpath->pict;
            $ppcp = $xmlpath->ppcp;
            $tmin = $xmlpath->t->min;
            $tmax = $xmlpath->t->max;
            $pmin = $xmlpath->p->min;
            $pmax = $xmlpath->p->max;
            $wmin = $xmlpath->wind->min;
            $wmax = $xmlpath->wind->max;
            $wrumb = $xmlpath->wind->rumb;
            $hmin = $xmlpath->hmid->min;
            $hmax = $xmlpath->hmid->max;
            $wpi = $xmlpath->wpi;
            $city = intval($city);
          }
    }

}

?&gt;

whis work! but on every line whith "$xmlpath->..." i have per line for two similar errors

Quote:A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: libraries/Weather.php
Line Number: 22 <- every line whith "$xmlpath->..."

what is wrong?


Messages In This Thread
"Notice" in my lib, xml trouble - by El Forum - 02-13-2008, 12:26 AM
"Notice" in my lib, xml trouble - by El Forum - 02-13-2008, 01:04 AM
"Notice" in my lib, xml trouble - by El Forum - 02-13-2008, 01:07 AM
"Notice" in my lib, xml trouble - by El Forum - 02-13-2008, 01:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB