Jump to content

The script tried to execute a method or access a property of an incomplete objec


jordanwb

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.