jordanwb Posted March 21, 2008 Share Posted March 21, 2008 Fatal error: jukebox::active_playlist() [<a href='function.jukebox-active-playlist'>function.jukebox-active-playlist</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "playlist" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in E:\xampp\htdocs\jukebox\plugins\jukebox.php on line 398 <?php class playlist { private $songs; function playlist ($songs = null) { if ($songs != null) { if (is_array ($songs)) { $this->songs = array (); foreach ($songs as $index => $song_path) { if (is_string ($song_path)) { $this->songs[] = $song_path; } } } } } function add_song ($song_path, $song_id) { $this->songs[] = array ($song_path, $song_id); } function remove_song ($list_position) { $playlist_length = count ($this->songs); if ($list_position < $playlist_length) { unset ($this->songs[$list_position]); for ($i = $list_position + 1; $i < $playlist_length; $i++) { $this->songs[$i-1] = $this->songs[$i]; } unset ($this->songs[$playlist_length-1]); return true; } else { return false; } } function clear_playlist () { $this->songs = array (); } function write_m3u_playlist () { header('Content-type: audio/x-mpegurl'); if (preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) { header("Content-Disposition: filename=\"playlist.m3u\""); } else { header("Content-Disposition: inline; filename=\"playlist.m3u\""); } foreach ($this->songs as $index => $song) { echo $song[0]."\n"; } die (""); } function song_list () { return $this->songs; } } class jukebox { function jukebox () { global $session; if (!isset ($_SESSION['active_playlist'])) // Active platlist doesn't exist { if ($session->is_logged_in) // Logged in { $_SESSION['active_playlist'] = new playlist (); } } else // Playlist exists { if (!$session->is_logged_in) // Not logged in { unset ($_SESSION['active_playlist']); // Unset the playlist } } } } ?> Now that's all well and good, the object is created, no errors. On line 398 is the following line of code: $_SESSION['active_playlist']->add_song ($song_path, $song_id); Both variables are created and have a value. Link to comment https://forums.phpfreaks.com/topic/97267-the-script-tried-to-execute-a-method-or-access-a-property-of-an-incomplete-objec/ Share on other sites More sharing options...
mb81 Posted March 21, 2008 Share Posted March 21, 2008 Remove the space between add_song and the ( ? Link to comment https://forums.phpfreaks.com/topic/97267-the-script-tried-to-execute-a-method-or-access-a-property-of-an-incomplete-objec/#findComment-497718 Share on other sites More sharing options...
jordanwb Posted March 23, 2008 Author Share Posted March 23, 2008 No that wouldn't make a difference. It seems that the playlist object hasn't been created when it get's to that line. Even though PHP had gone through about 1000 lines of code then. Link to comment https://forums.phpfreaks.com/topic/97267-the-script-tried-to-execute-a-method-or-access-a-property-of-an-incomplete-objec/#findComment-499029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.