IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Fatal error: Call to a member function children() on a non-object in


Sujet :

PHP & Base de données

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Juillet 2015
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Brazzaville

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Services à domicile

    Informations forums :
    Inscription : Juillet 2015
    Messages : 3
    Par défaut Fatal error: Call to a member function children() on a non-object in
    bonjour pourriez vous m'aider a corriger ceci je suis nul en programmation j'apprend encore

    Nom : Screenshot_409.png
Affichages : 329
Taille : 7,9 Ko


    et voici le code en ce ligne Nom : Screenshot_410.png
Affichages : 322
Taille : 3,3 Ko

    comment y remédier je précise que je suis encore débutant

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    Ca signifie que $entry n'est pas un objet.
    Donc il faut regarder le code qui initialise $entry.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Futur Membre du Club
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Juillet 2015
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Brazzaville

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Services à domicile

    Informations forums :
    Inscription : Juillet 2015
    Messages : 3
    Par défaut
    voici tout le code

    Code PHP : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    <?php
    if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     
    class Crud_model extends Model {
     
    	function Crud_model() {
    		parent::Model();
    	}
    ////user///////////////////////////////
    	function admin_login($username,$password)	{
    		if($username=="" || $password=="")
    			return false;
    		$sql = "SELECT * FROM admin WHERE username = ? AND password = ?";
    		$query=$this->db->query($sql, array($username,$password));
    		if ($query->num_rows() > 0)
    			return true;
    		else
                return false;
    	}
    	function retrieve_password()
    	{
    		$query=$this->db->get('user');
            return $query->result();
    	}
    	function update_password($password_new)
    	{
    		$sql = "UPDATE user SET `password` = '$password_new' ";
    		$query=$this->db->query($sql);
    	}
    ////facebook user///////////////////////
    	function create_facebook_user($data)
    	{
    		$sql = $this->db->insert_string('facebook_user', $data);
    		$query=$this->db->query($sql);
    	}
    	function retrieve_facebook_user()
    	{
    		$query=$this->db->get('facebook_user');
            return $query->result();
    	}
    ////category////////////////////////////
    	function create_category($name)
    	{
    		$sql = "INSERT INTO category(`name`) VALUES ('$name') ";
    		$query=$this->db->query($sql);
    	}
    	function retrieve_category_all()
    	{
    		$query = $this->db->get('category');	
            return $query->result();
    	}
    	function retrieve_category_name($category_id)
    	{
    		$this->db->where('category_id' , $category_id );
    		$query = $this->db->get('category');
    		$result = $query->result();
            foreach($result as $row)
    			return $row->name;
    	}
    	function delete_category($name)
    	{
    		$sql = $this->db->delete('category', array('name' => $name)); 
    		//$query=$this->db->query($sql);
    	}
    	function update_category($data,$category_id)
    	{
    		$this->db->where('category_id' , $category_id);
    		$this->db->update('category',$data);
    	}
    ////site_info////////////////////////////	
    	function retrieve_site_info()
    	{
    		$query=$this->db->get('site_info');
            return $query->result();
    	}
    	function update_site_info($data)
    	{
    		$this->db->update('site_info',$data);
    	}
    /////admin///////////////////////////
    	function retrieve_admin()
    	{
    		$query=$this->db->get('admin');
            return $query->result();
    	}
    	function update_admin($data)
    	{
    		$this->db->update('admin',$data);
    	}
    /////video//////////////////////////////
    	function create_video($data)
    	{
    		$sql = $this->db->insert_string('video', $data); 
    		$query=$this->db->query($sql);
    	}
    	function retrieve_video($sort)
    	{
    		$this->db->order_by($sort, "desc");
    		$this->db->limit(12);
    		$this->db->where('valid', 1);
    		$query=$this->db->get('video');
            return $query->result();
    	}
    	function retrieve_video_all($sort , $category_id, $featured, $limit = NULL, $offset = 0)
    	{
    		if($sort == 'recent')
    		{
    			$sort = 'id';
    		}
    		else if($sort == 'viewed')
    		{
    			$sort = 'viewed';
    		}
    		else $sort = 'id';
    		$this->db->order_by($sort, "desc");
    		if($category_id != 'all')
    		{
    			$this->db->where('category_id', $category_id);
    		}
    		if($featured == 'featured')
    		{
    			$this->db->where('featured', 1);
    		}
    		$query = $this->db->get('video',$limit, $offset);	
    		return $query->result_array();
    	}
    	function retrieve_single_video($id)
    	{
    		$this->db->where('id', $id);
    		$query=$this->db->get('video');
            $result = $query->result_array();
    		foreach($result as $video_data)return $video_data;		
    	}
    	function retrieve_video_rss()
    	{
    		//$this->db->order_by('id', "desc");
    		$query=$this->db->get('video' , 20,0);
            return $query->result();
    	}
    	function count_video_by_category($category_id)
    	{
    		$this->db->where('category_id', $category_id);
    		$query=$this->db->get('video');
    		return $query->num_rows();
    	}
    	function update_video_viewed($id)
    	{
    		//$this->db->where('id' , $id);
    		//$this->db->update('video',$data);
     
    		$sql = "UPDATE `video` SET `viewed` = `viewed`+1 WHERE `video`.`id` ='$id' LIMIT 1 ;";
    		$query=$this->db->query($sql);
    	}
    	function delete_video($id)
    	{
    		//$query=$this->db->query($sql);
    		$sql = $this->db->delete('video', array('id' => $id)); 
    	}
    	function youtube_gdata($mode = NULL , $limit = NULL , $offset = 1, $string = NULL )
    	{
    		$query = $this->db->get('site_info');
            $key_res = $query->result_array();
    		foreach($key_res as $row)$key = $row['youtube_developer_key'];
     
    		if($mode == 'top_rated')
    			$url = 'https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?alt=rss&key='.$key;
     
    		if($mode == 'most_popular')
    			$url = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_popular?alt=rss&key='.$key;
     
    		if($mode == 'most_viewed')
    			$url = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_viewed?alt=rss&key='.$key;
     
    		if($mode == 'most_shared')
    			$url = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_shared?alt=rss&key='.$key;
     
    		if($mode == 'most_recent')
    			$url = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_recent?alt=rss&key='.$key;
     
    		if($mode == 'recently_featured')
    			$url = 'https://gdata.youtube.com/feeds/api/standardfeeds/recently_featured?alt=rss&key='.$key;
     
    		if($mode == 'related')
    			$url = 'https://gdata.youtube.com/feeds/api/videos/'.$string.'/related?alt=rss&key='.$key;
     
    		if($mode == 'search')
    			$url = 'https://gdata.youtube.com/feeds/api/videos?q='.$string.'&orderby=rating&start-index='.$offset.'&max-results='.$limit.'&v=2&alt=rss&key='.$key;
     
    		//---------------------------------------------------------------------------------------------------------------------
     
    		$this->load->library('RSSParser', array('url' => $url));
     
     
    		$data = $this->rssparser->getFeed($limit);
     
    		return $data ;
    		//foreach ($data as $item) :
    			// $details = $this->crud_model->get_video_details($this->get_youtube_id($item['link']));
    		//endforeach;  
    	}
     
     
    	function get_video_details($youtube_id = NULL)
    	{
     
    		$query = $this->db->get('site_info');
            $key_res = $query->result_array();
    		foreach($key_res as $row)$key = $row['youtube_developer_key'];
     
    		// set video data feed URL
    		$feedURL = 'http://gdata.youtube.com/feeds/api/videos/'. $youtube_id.'?key='.$key;
     
    		// read feed into SimpleXML object
    		$entry = simplexml_load_file($feedURL);
     
    		// parse video entry
    		$video_info = $this->parseVideoEntry($entry);
     
    		$video['title']			= $video_info->title;
    		$video['type']			= 'youtube';
    		$video['video_id']		= $youtube_id;
    		$video['description']	= $video_info->description;
    		//$video['keywords']		= $video_info->keywords;
    		$video['thumbnail']		= $video_info->thumbnailURL;
    		$video['duration']		= $video_info->length;
    		$video['url_web']		= $video_info->watchURL;
    		$video['youtube_id']	= $youtube_id;
    		$video['url_embed']		= 'http://www.youtube.com/embed/'.$youtube_id;
    		$video['category']		= '';
     
    		//print_r($video);
    		return $video;		
    	}
    	function parseVideoEntry($entry) {      
          $obj= new stdClass;
     
          // get nodes in media: namespace for media information
          $URL = "http://search.yahoo.com/mrss/";
    $media = simplexml_load_file($URL);
          $obj->title = $media->group->title;
          $obj->description = $media->group->description;
     
          // get video player URL
          @$attrs = $media->group->player->attributes();
          $obj->watchURL = $attrs['url']; 
     
          // get video thumbnail
          $attrs = $media->group->thumbnail[0]->attributes();
          $obj->thumbnailURL = $attrs['url']; 
     
          // get <yt:duration> node for video length
          $yt = $media->children('http://gdata.youtube.com/schemas/2007');
          $attrs = $yt->duration->attributes();
          $obj->length = $attrs['seconds']; 
     
          // get <yt:stats> node for viewer statistics
          $yt = $entry->children('http://gdata.youtube.com/schemas/2007');
          $attrs = $yt->statistics->attributes();
          $obj->viewCount = $attrs['viewCount']; 
     
          // get <gd:rating> node for video ratings
          $gd = $entry->children('http://schemas.google.com/g/2005'); 
          if ($gd->rating) { 
            $attrs = $gd->rating->attributes();
            $obj->rating = $attrs['average']; 
          } else {
            $obj->rating = 0;         
          }
     
          // get <gd:comments> node for video comments
          $gd = $entry->children('http://schemas.google.com/g/2005');
          if ($gd->comments->feedLink) { 
            $attrs = $gd->comments->feedLink->attributes();
            $obj->commentsURL = $attrs['href']; 
            $obj->commentsCount = $attrs['countHint']; 
          }
     
          // get feed URL for video responses
          $entry->registerXPathNamespace('feed', 'http://www.w3.org/2005/Atom');
          $nodeset = $entry->xpath("feed:link[@rel='http://gdata.youtube.com/schemas/
          2007#video.responses']"); 
          if (count($nodeset) > 0) {
            $obj->responsesURL = $nodeset[0]['href'];      
          }
     
          // get feed URL for related videos
          $entry->registerXPathNamespace('feed', 'http://www.w3.org/2005/Atom');
          $nodeset = $entry->xpath("feed:link[@rel='http://gdata.youtube.com/schemas/
          2007#video.related']"); 
          if (count($nodeset) > 0) {
            $obj->relatedURL = $nodeset[0]['href'];      
          }
     
          // return object to caller  
          return $obj;      
        }
     
     
     
     
    }


    comment je le regle apres

  4. #4
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    Ajoute un contrôle des erreurs à la ligne 215 :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    $entry = simplexml_load_file($feedURL);
    if ($entry=== false) {
        echo "Erreur lors du chargement du XML\n";
        foreach(libxml_get_errors() as $error) {
            echo "\t", $error->message;
        }
    exit();
    }
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  5. #5
    Futur Membre du Club
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Juillet 2015
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Brazzaville

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Services à domicile

    Informations forums :
    Inscription : Juillet 2015
    Messages : 3
    Par défaut
    voila ce que je trouve une fois fait ce que vous m'aviez dit
    Nom : Screenshot_411.png
Affichages : 300
Taille : 2,3 Ko

Discussions similaires

  1. Réponses: 23
    Dernier message: 26/02/2011, 12h38
  2. Réponses: 4
    Dernier message: 07/10/2009, 11h53
  3. Réponses: 4
    Dernier message: 02/10/2009, 10h12
  4. [PDO] Fatal error: Call to a member function setFetchMode() on a non-object in
    Par tores20 dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 28/07/2009, 23h04
  5. [PHP 5.2] Fatal error: Call to a member function bindValue() on a non-object
    Par TeraD dans le forum Langage
    Réponses: 4
    Dernier message: 23/06/2009, 00h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo