[PHP]Cannot redeclare class

Pagina: 1
Acties:
  • 2.329 views sinds 30-01-2008

  • Spoooky
  • Registratie: September 2002
  • Laatst online: 02-04 14:18

Spoooky

Core temp 37°C

Topicstarter
Ik draai xampp 1.5.0 met virtual hosts en mod_rewrite enabled. Bovendien draait er hMailserver, die de MySQL van xampp gebruikt.

Ik draai op een van die virtual hosts ( [url=http:\\blog.spoooky.nl]http:\\blog.spoooky.nl[/url] )boastmachine ( www.boastology.com ). Ik krijg helaas regelmatig de volgende foutmelding.

Fatal error: Cannot redeclare class bdb in C:\Websites\blog\bmc\inc\core\db_mysql.php on line 29

Als ik dan de pagina refresh, laadt de pagina gewoon. Kan iemand mij helpen om dit probleem op te lossen?

Ik ben spuit 1011, aangenaam!


  • Koetjeboe
  • Registratie: Maart 2002
  • Laatst online: 10-04 14:50

Koetjeboe

Boe, zegt de koe

Nouja, zondere verdere informatie, include je alles via include_once?

  • Spoooky
  • Registratie: September 2002
  • Laatst online: 02-04 14:18

Spoooky

Core temp 37°C

Topicstarter
<?php

/*
===========================

boastMachine v3.1
Released : Sunday, June 5th 2005 ( 06/05/2005 )
http://boastology.com

Developed by Kailash Nadh
Email : mail@kailashnadh.name
Website : http://kailashnadh.name, http://bnsoft.net
Blog : http://boastology.com/blog

boastMachine is a free software licensed under GPL (General public license)

===========================
*/

// The boastMachine database class :)

$proc_name="MySQL";
// The name of the database this class is currently processing

$debug_mode=true;
// Run in Debug mode? Running in debug mode will produce error messages
// when one occurs, else, no messages will be produced but a -1 will be returned by the function

class bDb {

var $my_prefix; // The mysql table prefix
var $link; // this object the MysqL connection handle
var $last_query=null; // Holds the copy of the last query
var $last_result=null; // Holds the last result of query
var $num_rows=0;
var $result=null;
var $output=null;

// The constructor. Get the mysql info vars and connect to the server
function bDb() {
global $my_host,$my_user,$my_pass,$my_db,$my_prefix;

$this->link = mysql_connect($my_host,$my_user,$my_pass); // Connect to the MySQL server

// Cant connect to the server!
if(!$this->link) {
die(mysql_error());
}

// Cant select the database!
if(!@mysql_select_db($my_db,$this->link)) {
die(mysql_error());
}
}


// Perform the MySQL queries
function query($query_str,$multi=true) {

$row=null;
$num=0;
$this->last_query=null;
$this->result=null;
$this->output=null;
$this->output=array();

if(!$query_str) { return 0; } // If there is no query string, return 0

$this->last_query = $query_str;
$this->result = mysql_query($query_str, $this->link) or die(mysql_error()); // Do the query

if ( preg_match("/^\\s*(insert|delete|update|replace) /i",$query_str) ) {
$this->rows_done = mysql_affected_rows();
// Return the number of rows affected by this operation
return $this->rows_done;

} else {

// Return multiple rows stored in a multi dimensional array
if($multi) {
// If the query was to get data, i.e, select, then return the data as arrays

while ( $row = mysql_fetch_array($this->result, MYSQL_ASSOC) ) {
$this->output[$num] = $row;
$num++;
}
}


else {
// Return the result in a one dimensional array
return mysql_fetch_array($this->result, MYSQL_ASSOC);
}

return $this->output; // Return the multi demensional array
}

} // End function


// Get the number of rows for a particular query
function row_count($row) {
if(!$row) return 0;
return mysql_num_rows(mysql_query($row,$this->link));
}

// Show error messages - DEBUG MODE
function show_error($error_msg) {
global $debug_mode;

if($debug_mode) {
echo $error_msg;
} else {
return;
}
}

} // End class

?>

Ik ben spuit 1011, aangenaam!


  • Sybr_E-N
  • Registratie: December 2001
  • Laatst online: 08-04 21:55
Kans is erg groot dat je meerdere malen deze bovenstaande file include. Dan probeert PHP een class aan te maken, maar de tweede keer gaat dat fout omdat deze immers al bestaat. Je zult dus eerst ook uit moeten zoeken, hoevaak en waar bovenstaand bestand wordt geinclude.

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 11-03 14:33

NMe

Quia Ego Sic Dico.

Ik stel voor dat je die goeie meneer Kailash Nadh even een mailtje stuurt of zijn site even bezoekt. We zijn hier niet het BoastMachine-supportforum. In Programming & Webscripting programmeren we onze code zelf, en als je problemen hebt met de code van derden, dan vecht je dat maar met de maker ervan uit. ;)

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Dit topic is gesloten.