0

Hi,
I have a trouble with my script. Everytime I execute index.php, and call add_schedule, always appear message:
Fatal error: Call to a member function add_schedule_form() on a non-object in index.php on line 19.
I have try to fix by changing the syntax on line 19 (index.php) but it just was the same.
Can anybody help me to solve this problem? My programming is not so good, but I like programming.
I am trying to develop a reservation system for my final thesis.
Thankyou.

// file: system_class.php
<?php
	class system_class {
		var $mysql;
		var $err_msg;
		var $message;

		function system_class()
		{	// variable for error message
			global $text;
			$this->mysql=new mysql_manager('');
			$this->err_msg=$text;}

		function add_schedule_form() {
			$form_template=file_get_contents('tpl/add_schedule.tpl.php'); 
			$form_template=str_replace('msg',$this->message,$form_template);
			$output=$form_template;
			return $output;
		}
        }
?>
// file: index.php
<?php
	ob_start() ;
	session_start();
	$d = dirname(__FILE__); 
	include $d.'/syst/system_class.php';
	$action=$_GET['action'];
?>

<html><head></head><body>
<?php
	function index() {
		print(“<a href=\”index.php?action=add_schedule\”>add schedule</a>”);
	}

	function add_schedule() {
		global $login;
	 
		echo $login->add_schedule_form(); 
	}
	
	switch ($action) {
		case "add_schedule": add_schedule(); break;
				 
		//load the default function.
		Default: index(); Break;
	}
	ob_end_flush(); 
?>

</body></html>
4
Contributors
4
Replies
7
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

you should create object of class system_class.
then only all function of that class can be used.

0

You can solve the issue by creating the object like below in your index.php

function add_schedule() {
 $login='system_class';
 $obj = new $login;
 echo $obj->add_schedule_form(); 
}

It will work!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.