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>

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

Member Avatar for rajarajan2017

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!

Hi, it's work! ^^ .. Thanks a lot

Member Avatar for rajarajan2017

Please Mark the thread as solved! If it is solved!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.