Kann es sein dass der gepostete code includet wird? Und durch irgendeinen dummen zufall 2 mal?
Fatal error: Cannot redeclare startelement()
Einklappen
X
-
-
Hmm, nur wenn ein Include in einer While-Schleife auch als redeklaration gilt:
soldnerstats.php:
PHP-Code:<?php
error_reporting(E_ALL);
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
require("config.inc"); // Verbindungsdaten zur DB
$dbconn = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
$success = mysql_select_db($mysql_db);
$abfrage = "SELECT * FROM $xmlfiles";
$ergebnis = mysql_query($abfrage);
while($row = mysql_fetch_object($ergebnis))
{
$file = $row->file;
$xmlFile = file($file);
include("process.inc");
}
mysql_close($dbconn);
flush();
?>
PHP-Code:<?
$mysql_host = "localhost"; // Server
$mysql_db = "sstats"; // Database
$mysql_user = "root"; // Username
$mysql_pass = ""; // Password
$players = "players";
$xmlfiles = "xmlfiles";
PHP-Code:<?php
error_reporting(E_ALL);
include('config.inc');
print $file;
$dbconn = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
mysql_select_db($mysql_db);
$XMLEntities = array(
'&' => '&',
'<' => '<',
'>' => '>',
//''' => '\'',
'"' => '"'
);
$noteam=0; // Var für Fallabfrage PLAYER_HAS_NO_TEAM
// Leermachen
$sql_player_table = "TRUNCATE Table Players";
$result_player_table = mysql_query($sql_player_table) or die(mysql_error());
/* Zeile 23 */ function startElement(&$parser, &$element_name, &$element_attribute)
{
global $XMLEntities, $idout, $noteam;
mysql_query("CREATE TABLE $file (
'CASH' int(8) NOT NULL default '0',
'COMMANDER' char(3) collate latin1_general_ci NOT NULL default '',
`DEATHS` int(8) NOT NULL default '0',
`KILLS` int(8) NOT NULL default '0',
`NAME` varchar(100) collate latin1_general_ci NOT NULL default '',
`TEAM` smallint(1) NOT NULL default '0',
PRIMARY KEY (`NAME`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;");
$element_name = strtolower($element_name); # Element in Kleinbuchstaben
$felder = array();
$werte = array();
foreach ($element_attribute as $Key => $Value)
{
$felder[] = $Key; # Attributnamen in Array
$werte[] = strtr(trim($Value), $XMLEntities);
}
if($element_name == "player")
{
$feld_str = implode(', ', $felder);
$wert_str = "'" . implode("', '", $werte) . "'";
$sql_player_table = "INSERT INTO $file ($feld_str) VALUES ($wert_str)";
$result_player_table = mysql_query($sql_player_table) or die(mysql_error());
if($noteam != 0)
{
$sql_player_table = "UPDATE $file SET TEAM = '$idout' WHERE TEAM = '0'";
$result_player_table = mysql_query($sql_player_table) or die(mysql_error());
$log = mysql_affected_rows();
$log++;
}
else
{
$sql_player_table = "UPDATE $file SET TEAM = '0' WHERE TEAM = '0'";
$result_player_table = mysql_query($sql_player_table) or die(mysql_error());
}
}
//Nächste Zeile ist der can't redaclare Fehler
/* Zeile 66 */ }
function endElement($parser, $element_name)
{
global $idout,$noteam;
$element_name = strtolower($element_name);
if($element_name == "team")
{
$noteam--;
}
}
$parser = xml_parser_create('');
xml_set_element_handler($parser, "startElement", "endElement");
foreach($xmlFile as $elem)
{
xml_parse($parser, $elem);
}
xml_parser_free($parser);
?>
Ich hoffe ihr könnt mir helfen.
Danke!
cu
robertthronhill
Kommentar
-
Original geschrieben von robertthronhill
Hmm, nur wenn ein Include in einer While-Schleife auch als redeklaration giltI don't believe in rebirth. Actually, I never did in my whole lives.
Kommentar
-
??? Hab ich was ganz grob falsch gemacht? Ich bin Anfänger.
@wahsaga: Also ist es kein Problem wenn ichs so mache, richtig?
cu
robertthronhillZuletzt geändert von robertthronhill; 17.02.2005, 16:07.
Kommentar
-
es gibt btw auch include_once()
Kommentar
-
Original geschrieben von MelloPie
welchen sinn macht ein include wohl in einer schleife???
Kommentar
Kommentar