Page 1 of 1

Errors what do i do?

Posted: Sat Aug 06, 2005 7:17 pm
by gaogier
i have looked in my php book, spoono and they dont help

Fatal error: Cannot instantiate non-existent class: cash_menucat in /home/gaogier/public_html/forums/admin/admin_cash.php on line 32

the code

Code: Select all

<?php
/***************************************************************************
 *                              admin_cash.php
 *                            -------------------
 *   begin                : Monday, Aug 18, 2003
 *   copyright            : (C) 2003 Xore
 *   email                : mods@xore.ca
 *
 *   $Id: admin_cash.php,v 1.1.0.0 2003/09/18 23:03:34 Xore $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

if ( !defined('ADMIN_MENU') )
{
	define('ADMIN_MENU',1);
	function admin_menu(&$menu)
	{
		global $lang;
		$i = 0;
		$j = 0;
		
$menu[$i] = new cash_menucat($lang['Cmcat_main']);
		$menu[$i]->additem(new cash_menuitem($j,	'Cash_Configuration',	'cash_config',		$lang['Cmenu_cash_config']));
		$menu[$i]->additem(new cash_menuitem($j,	'Cash_Currencies',		'cash_currencies',	$lang['Cmenu_cash_currencies']));
		$menu[$i]->additem(new cash_menuitem($j,	'Cash_Forums',			'cash_forums',		$lang['Cmenu_cash_forums']));
		$menu[$i]->additem(new cash_menuitem($j,	'Cash_Settings',		'cash_settings',	$lang['Cmenu_cash_settings']));
		$i++;
		$menu[$i] = new cash_menucat($lang['Cmcat_addons']);
		$menu[$i]->additem(new cash_menuitem($j,	'Cash_Events',			'cash_events',		$lang['Cmenu_cash_events']));
		$menu[$i]->additem(new cash_menuitem($j,	'Cash_Reset',			'cash_reset',		$lang['Cmenu_cash_reset']));
		$i++;
		$menu[$i] = new cash_menucat($lang['Cmcat_other']);
		$menu[$i]->additem(new cash_menuitem($j,	'Cash_Exchange',		'cash_exchange',	$lang['Cmenu_cash_exchange']));
		$menu[$i]->additem(new cash_menuitem($j,	'Cash_Groups',			'cash_groups',		$lang['Cmenu_cash_groups']));
		$menu[$i]->additem(new cash_menuitem($j,	'Cash_Logs',			'cash_log',			$lang['Cmenu_cash_log']));
		$i++;
		$menu[$i] = new cash_menucat($lang['Cmcat_help']);
		$menu[$i]->additem(new cash_menuitem($j,	'Cash_Help',			'cash_help',		$lang['Cmenu_cash_help']));
	}
}
their are loads of these errors since i updated the forums

please help

btw the book is called "php and mysql for dynamic websites"

Posted: Sat Aug 06, 2005 7:22 pm
by feyd
the error purely means that a class definition for 'cash_menucat' wasn't included at run-time. So you must have a file laying around that has this class definition in it.. make sure it's included in the main admin file (I guess)

Posted: Sat Aug 06, 2005 7:34 pm
by gaogier
this is due to me updating the forums

Posted: Sat Aug 06, 2005 7:36 pm
by gaogier
how do i find out what the line of code is without counting them all?

Posted: Sat Aug 06, 2005 7:58 pm
by feyd
it's easier to use an editor with line numbering.. (they have been discussed a lot in the "favorite editors" thread in the general forum)

Posted: Sat Aug 06, 2005 9:19 pm
by shoebappa
Who needs fancy editors... In Notepad, make sure Word Wrap is off under Format. Then under Edit, there's a GoTo option that lets you enter a line number.

Posted: Sun Aug 07, 2005 10:37 am
by Chris Corbyn
shoebappa wrote:Who needs fancy editors... In Notepad, make sure Word Wrap is off under Format. Then under Edit, there's a GoTo option that lets you enter a line number.
Notepad is an editor and also discussed in that thread. Let's try to keep this thread on-topic ;)

Posted: Sun Aug 07, 2005 10:42 am
by gaogier
any ideas on what i need to do?

Posted: Sun Aug 07, 2005 10:47 am
by Chris Corbyn
You need to find which file contains the class and then include() or require() it before it's instantiated with $classname = new classname(); ;)

It's way too vague for us to be more specific than that because you'll have lots of files and we wont know whats in them all.

Posted: Sun Aug 07, 2005 7:13 pm
by gaogier
i dont understand

Posted: Sun Aug 07, 2005 7:16 pm
by feyd
figure .. out .. which .. file .. the .. class .. is .. defined .. in.
include() .. it .. in .. a .. central .. location.

last time I try this..... :?

Posted: Mon Aug 08, 2005 10:38 am
by Ambush Commander
A class is a blueprint. PHP becomes aware of this blueprint during a script when the file the blueprint is included is "included" into the script. If the page with the blueprint is never included, then PHP does not have a blueprint, so it cannot create the class ("the structure the blueprint describes"). Therefore, you must makesure PHP has the blueprint.