Hallo!
Ich habe ein Problem mit diesem Script:
Es kommen diese Fehler:
Er scheint bei den beiden Dateien 2 verschiedene probleme zu haben, obwohl sie exakt den gleichen Inhalt haben.
Kann mir jemand weiterhelfen?
Danke schon im Vorraus!
cu
robertthronhill
Ich habe ein Problem mit diesem Script:
PHP Code:
<?php
error_reporting(E_ALL);
include('config.inc');
$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_soldner_table = "TRUNCATE Table Server";
$result_soldner_table = mysql_query($sql_soldner_table) or die(mysql_error());
$sql_soldner_table = "TRUNCATE Table Teams";
$result_soldner_table = mysql_query($sql_soldner_table) or die(mysql_error());
$sql_soldner_table = "TRUNCATE Table Players";
$result_soldner_table = mysql_query($sql_soldner_table) or die(mysql_error());
function startElement(&$parser, &$element_name, &$element_attribute)
{
global $XMLEntities, $idout, $noteam;
$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 == "game")
{
$feld_str = implode(', ', $felder);
$wert_str = "'" . implode("', '", $werte) . "'";
$sql_soldner_table = "INSERT INTO Server ($feld_str) VALUES ($wert_str)";
$result_soldner_table = mysql_query($sql_soldner_table) or die(mysql_error());
}
if($element_name == "team")
{
$noteam++;
$feld_str = implode(', ', $felder);
$wert_str = "'" . implode("', '", $werte) . "'";
$sql_team_table = "INSERT INTO Teams ($feld_str) VALUES ($wert_str)";
$result_team_table = mysql_query($sql_team_table) or die(mysql_error());
$idout = $werte[2];
}
if($element_name == "player")
{
$feld_str = implode(', ', $felder); #
$wert_str = "'" . implode("', '", $werte) . "'";
$sql_player_table = "INSERT INTO Players ($feld_str) VALUES ($wert_str)";
$result_player_table = mysql_query($sql_player_table) or die(mysql_error());
if($noteam != 0)
{
$sql_player_table = "UPDATE Players 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 Players 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 91 */ }
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");
//nachste Zeile kommt die Warnung
/* Zeile 109 */ foreach($xmlFile as $elem)
{
xml_parse($parser, $elem);
}
xml_parser_free($parser);
?>
Kopievontest.xml
Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\MightyStats\process.inc on line 128
test.xml
Fatal error: Cannot redeclare startelement() (previously declared in D:\xampp\htdocs\MightyStats\process.inc:42) in D:\xampp\htdocs\MightyStats\process.inc on line 108
Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\MightyStats\process.inc on line 128
test.xml
Fatal error: Cannot redeclare startelement() (previously declared in D:\xampp\htdocs\MightyStats\process.inc:42) in D:\xampp\htdocs\MightyStats\process.inc on line 108
Kann mir jemand weiterhelfen?
Danke schon im Vorraus!
cu
robertthronhill
Comment