Page 1 of 1
Fatal error: Call to undefined method...?
Posted: Tue Jun 26, 2007 5:50 am
by mcccy005
Alrighty, for the life of me I can't work out why I get this following error:
Fatal error: Call to undefined method result_field::load_result_page() in S:\Web_Pages\Object_Library\Result_Set\result_page.php on line 16
Here's the code for the constructor in result_page.php:
Code: Select all
public function __construct($fields_array, $table_width=null, $table_border=1)
{
$this->fields_array=$fields_array;
for($i=0; $i<sizeof($this->fields_array); $i++) //Creates a reference to each result_field object within $fields_array
/*Line 16*/ $this->fields_array[$i]->load_result_page($this);
$this->table_width=$table_width;
$this->table_border=$table_border;
}
And heres the method load_result_page( ) in result_field.php:
Code: Select all
public function load_result_page($parent_result_page)
{
$this->parent_result_page=$parent_result_page;
}
For the record (if it matters), result_field extends result_page and result_page extends another object.
I have tested the values in the variable $this->fields_array using get_class( ) and confirmed that they are of type result_field as they should be.
ANy ideas whatsoever??
Thanks
Posted: Tue Jun 26, 2007 6:12 am
by volka
no idea. Please try
Code: Select all
public function __construct($fields_array, $table_width=null, $table_border=1)
{
$this->fields_array=$fields_array;
for($i=0; $i<sizeof($this->fields_array); $i++) { //Creates a reference to each result_field object within $fields_array
echo '<div>Debug class: ', get_class($this->fields_array[$i]), "</div>\n";
echo '<pre>Debug methods: '; print_r(get_class_methods($this->fields_array[$i])); echo "</pre>\n";
$this->fields_array[$i]->load_result_page($this);
}
$this->table_width=$table_width;
$this->table_border=$table_border;
}
Posted: Tue Jun 26, 2007 6:22 am
by mcccy005
Debug class: result_field
Debug methods: Array
(
[0] => __construct
[1] => display
[2] => get_cells
[3] => set_bg_color
[4] => get_bg_color
)
And still get the error.
Here is the code before and after the load_result_page method:
Code: Select all
<?php
/*This class creates one row (ie. result field) which displays values/data stored within an array. */
class result_field extends result_page
{
protected $cells_array, //Stores an array of result_cell objects
$reference, //html link to each value in the entire row/field. Each value in the field links to the same webpage
$bg_color, //background colour of row
$is_title, /*If this field is the title of a set of result_fields [ie. a result_set] then the link ($reference) will initiate a relisting of the values based
on a sort function which may relist all values based on A->Z or Z->A; or 0->9; or 9->0; or bool (for all true or false values up the top) */
$parent_result_page; //Stores an instance of the result_field object with which this cell object will be stored in
/* Constructor - creates a new result_field object */
public function __construct($cells_array, $reference=null, $bg_color="#F0F8FF", $is_title=null)
{
$this->cells_array=$cells_array;
for($i=0; $i<sizeof($this->cells_array); $i++) //Creates a reference to each cell object within $cells_array
$this->cells_array[$i]->load_result_field($this);
$this->reference=$reference;
$this->bg_color=$bg_color;
$this->is_title=$is_title;
}
/* Creates an instance of the result_set object with which this result_field object will be stored in.
This function is called by the parent object (result_set) in the constructor */
public function load_result_page($parent_result_page)
{
$this->parent_result_page=$parent_result_page;
}
/*Outputs the html required for this particular row */
public function display( )
{
echo '<tr bgcolor="'.$this->bg_color.'">';
for($i=0; $i<sizeof($this->cells_array); $i++)
$this->cells_array[$i]->display( );
echo "</tr>";
}
Posted: Tue Jun 26, 2007 6:59 am
by volka
And still get the error.
Of course. Only debug output code has been added.
Please try
Code: Select all
class result_field extends result_page {
[...]
public function __construct($cells_array, $reference=null, $bg_color="#F0F8FF", $is_title=null)
{
echo '<div>Debug method:', __METHOD__, "</div>\n";
echo '<pre>Debug, my methods: '; print_r(get_class_methods($this)); echo "</pre>\n";
$this->cells_array=$cells_array;
for($i=0; $i<sizeof($this->cells_array); $i++) //Creates a reference to each cell object within $cells_array
$this->cells_array[$i]->load_result_field($this);
$this->reference=$reference;
$this->bg_color=$bg_color;
$this->is_title=$is_title;
}
and yes, this will still not fix anything, still debug output.