i have prob on code with error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
forgun
Forum Commoner
Posts: 61
Joined: Wed Jan 29, 2003 6:05 am
Contact:

i have prob on code with error

Post by forgun »

the error

Code: Select all

Fatal error: Cannot redeclare class func in /home/virtual/site3/fst/var/www/html/il-pc/includes/functions.php on line 2
the cone on that line is

Code: Select all

<?php
class func extends mysql {
	var $dt;
	function s_title($loc) {
		switch ($loc) {
			case "update":
			$this->dt = array (
			'title' => "UpDate Web Site" ,
			'js' => "./includes/bbcode.js"
			);
			break;
			case "menu":
			$this->dt = array (
			'title' => "UpDate Menu Web Site"
			);
			break;
			case "vote":
			$this->dt = array (
			'title' => "UpDate Vote System"
			);
			break;
			case "games":
			$this->dt = array (
			'title' => "UpDate Games Settings"
			);
			break;
			case "settings":
			$this->dt = array (
			'title' => "UpDate Main Setiings Web Site"
			);
			break;
		}
	}
}
?>
why????
here the plave that active the command

Code: Select all

<?php
include ("./includes/functions.php");
$st = new func();
$st->s_title($loc);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<SCRIPT src="<?= $st->dt['js'] ?>" language="javascript"></SCRIPT>
<title>IL-Vortex - PC ( <?= $st->dt['title'] ?> )</title>
plz help me
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

Are you including any other files (other than what's stated above) ? Where is the require/include for the "mysql" class, or is that above the "func" class ?

As a test, try:

Ref : http://uk.php.net/manual/en/function.ge ... -files.php

Regards,
User avatar
forgun
Forum Commoner
Posts: 61
Joined: Wed Jan 29, 2003 6:05 am
Contact:

Post by forgun »

mm yap
more two
i dont have
php 5.0
i have 4.3+
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

I think func is a reserved keyword by PHP. Try changing it to something like eggandchips and see if that works if that does then try and call it something that will not be repeated like func_class or something.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Also, when including class or function files, use include_once() or require_once() so that they aren't reincluded if they've already been included.

Mac
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

If your still having an issue, this is a useful method to check which classes have been declared in your script:

syntax : array get_declared_classes ( void )
Ref : http://uk.php.net/get_declared_classes

Regards,
Post Reply