Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-01-2005, 07:07 PM Class errors... HELP
Novice Talker

Posts: 7
Trades: 0
Fatal error: Cannot instantiate non-existent class: gim_db in /home/.mabeloven/mecharpg/mechaasylum.com/global/game/modules/country/country.php on line 23

Fatal error: Cannot instantiate non-existent class: gim_page in /home/.mabeloven/mecharpg/mechaasylum.com/global/game/prepare.php on line 50


What does this mean...

Spesificly this: Fatal error: Cannot instantiate non-existent class:


this is the coding for the first error:
Code:
class GIM_Country {
		var $id = -1;
		var $data = array();
		var $db = NULL;
		function GIM_Country() {
			$this->db = new GIM_DB;
		}
		function link($id) {
			if ($this->id == $id) return;
			$this->id = $id;
		}
		function fill($name, $id = -1) {
			if ($id == -1) $id = $this->id;
			$this->db->Query("SELECT $name FROM countries WHERE id='$id'");
			$this->db->Next();
			$this->data[$this->id] = $this->db->getAll();
		}
		function set($name, $val, $met = "") {
			$id = $this->id;
			if ($met != "") {
				$set = "$name = $name $met $val";
				if ($met == "+") $this->data[$id][$name] += $val;
				if ($met == "-") $this->data[$id][$name] -= $val;

			} else {
				$this->data[$id][$name] = $val;
				$set = "$name = $val";
			}
			$this->db->Query("UPDATE countries SET $set WHERE id='$id'");
		}

		function get($name, $id = -1) {
			if ($id == -1) $id = $this->id;


			if ($this->data[$id][$name] == NULL) {
				$this->db->Query("SELECT $name FROM countries WHERE id='$id'");
				$this->db->Next();
				$this->data[$id][$name] = $this->db->get($name);
			}
			return $this->data[$id][$name];
		}
		function getoil($id) {
			global $cdb;
			$cdb->query("SELECT oil FROM countries WHERE id='$id'");
			$cdb->Next();
			return $cdb->get("oil");
		}
		function getname($id) {
			global $cdb;
			$cdb->query("SELECT name FROM countries WHERE id='$id'");
			$cdb->Next();
			return $cdb->get("name");
		}
		function getlatlon($cid) {
			$db = new GIM_DB;
			$db->Query("SELECT * FROM countries WHERE id='$cid'");
			$db->Next();

			$info[0] = $db->Get("lat");
			$info[1] = $db->Get("lon");

			return $info;
		}
		function time($dist, $speed) {
			return $dist / $speed * 60 * 60;
		}
		function distance($c1, $c2, $unit = "K") {
			$l1 = $this->getlatlon($c1);
			$l2 = $this->getlatlon($c2);


			$lat1 = $l1[0];
			$lon1 = $l1[1];

			$lat2 = $l2[0];
			$lon2 = $l2[1];

			$theta = $lon1 - $lon2;

			$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
			$dist = acos($dist);

			$dist = rad2deg($dist);
			$dist = $dist * 60 * 1.1515;
			switch($unit) {
				case "M":
					break;
				case "K":
					$dist = $dist * 1.609344;
		      			break;
				case "N":
					$dist = $dist * 0.8684;
					break;
			}
		  return ($dist);
		}

	}
bobman is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-01-2005, 07:18 PM
Rufo's Avatar
Extreme Talker

Posts: 173
Trades: 0
'Cannot instantiate non-existent class' normally means that you have either not defined a class, or you have defined your classes in the wrong order.

Where abouts have you defined gim_db and gim_page?
__________________

Please login or register to view this content. Registration is FREE
Rufo is offline
Reply With Quote
View Public Profile Visit Rufo's homepage!
 
Old 04-01-2005, 07:20 PM
Novice Talker

Posts: 7
Trades: 0
oooh thanks! ill post more if i have other questions
bobman is offline
Reply With Quote
View Public Profile
 
Old 04-01-2005, 07:26 PM
Novice Talker

Posts: 7
Trades: 0
umm... what would i put in this spot

Code:
var $cID	= 0;
           var $qID 	= 0;
i know im suposed to put somthing where the zeros r... what?
bobman is offline
Reply With Quote
View Public Profile
 
Old 04-01-2005, 07:31 PM
devnull's Avatar
Skilled Talker

Posts: 87
Location: /dev/null
Trades: 0
One more small tip...
Are you sure you included the class file itself in your script file?
Just in case..
__________________

Please login or register to view this content. Registration is FREE
- ClickBank Profit Script

Please login or register to view this content. Registration is FREE
- Unlimited Free BitTorrents

Please login or register to view this content. Registration is FREE
- eg) proxyOHIO.info, proxyTexas.info, etc..
devnull is offline
Reply With Quote
View Public Profile Visit devnull's homepage!
 
Old 04-01-2005, 07:34 PM
Novice Talker

Posts: 7
Trades: 0
ya

Code:
class GIM_DB {

		var $Hostname	= "mysql.mechaasylum.com";
		var $Username	= "this is secret...";
		var $Password	= "this is secret...";
		var $Database	= "this is secret...";
		var $cID	= 0;
		var $qID 	= 0;

		var $Record	= array();
this is the index preparing script:

Code:
 include("$dir/modules/db/db.php");
	include("$dir/modules/page/page.php");
	include("$dir/modules/info/info.php");

	include("$dir/modules/user/user.php");
	include("$dir/modules/events/events.php");
	include("$dir/modules/country/country.php");
	include("$dir/modules/province/province.php");
	include("$dir/modules/script/script.php");
	include("$dir/modules/provarlist/provarlist.php");
	include("$dir/modules/uservarlist/uservarlist.php");
bobman is offline
Reply With Quote
View Public Profile
 
Old 04-01-2005, 07:41 PM
Rufo's Avatar
Extreme Talker

Posts: 173
Trades: 0
Quote:
Originally Posted by bobman
i know im suposed to put somthing where the zeros r... what?
That really depends what they are used for

Are you sure that GIM_DB is defined before it is used (i.e. before GIM_Country is defined)?
__________________

Please login or register to view this content. Registration is FREE
Rufo is offline
Reply With Quote
View Public Profile Visit Rufo's homepage!
 
Old 04-01-2005, 07:47 PM
Novice Talker

Posts: 7
Trades: 0
here is the full database script:

Code:
 class GIM_DB {

		var $Hostname	= "mysql.mechaasylum.com";
		var $Username	= "this is secret...";
		var $Password	= "this is secret...";
		var $Database	= "this is secret...";
		var $cID	= 0;
		var $qID 	= 0;

		var $Record	= array(); 

/* Connecting to DB.
		ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ*/
		function Connect() {

			if (!$this->cID) {

				$this->cID=mysql_pconnect($this->Hostname, $this->Username, $this->Password);

				if (!$this->cID) {

					$this->Halt("Couldnt connect to $this->Hostname");
					return false;
				}


				if (!mysql_select_db($this->Database,$this->cID)) {

					$this->Halt("Couldnt select $this->Database");
					return false;
				}
			}

			return true;
		}

		/* Free sql results.
		ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ*/
		function Free() {
			  @mysql_free_result($this->qID);
			  $this->qID = 0;

		}

		/* Sending Query
		ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ*/
		function Query($Query) {
			if ($Query == "") {
				//$this->Halt("Empty query");
				return 0;
			}
			if (!$this->Connect()) {
				return;
			}

			if ($this->qID) {
				$this->Free();
			}

			$start = getmicrotime();
			$this->qID = @mysql_query($Query,$this->cID);

			if (!$this->qID) {
				$this->Halt("Invalid SQL: $Query (" . mysql_error() . ")");

				return false;
			}
			$end = round((getmicrotime() - $start), 4);

			if ($end > 0.20 && 0) {
			?>
				<span class="error_msg"><pre><?= "$end sec ($Query)"; ?></pre></span><br>;
			<?
			}

			return true;
		}


		/* Get next result in array after Query()
		ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ*/
		function Next() {
			if (!$this->cID) {
				$this->Halt("Can not fetch while no query is pending...");
				return false;
			}

			$this->Record = mysql_fetch_array($this->qID);

			if (is_Array($this->Record)) return true;

			return false;

		}

		/* Get value of array fetched my Next
		ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ*/

		function Get($Name) {
			return $this->Record[$Name];
		}
		/* Get the entire result array.
		ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ*/

		function getall() {
			return $this->Record;
		}

		/* Return number of records current query has.
		ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ*/
		function affected_Rows() {
			return mysql_affected_rows($this->cID);
		}
		function num_Records() {
			return @mysql_num_rows($this->qID);
		}

		/* Something went wrong function.
		ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ*/
		function Halt($Msg = "") {
			echo $Msg;

		}
	}
bobman is offline
Reply With Quote
View Public Profile
 
Old 04-01-2005, 07:52 PM
Novice Talker

Posts: 7
Trades: 0
well i fixed the GIM_DB problem... the other one is still open...
bobman is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Class errors... HELP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.49183 seconds with 12 queries