Hallo!
Kann mir jemand sagen, wo ich in diesem Script:
was mit meiner $file Variable falsch mache, dass diese Fehler:
kommen? Ich nehme an, dass der MySQL Fehler dadurch zu stande kommt, dass die Tabelle, in die das Script die Daten reinschreiben soll, nicht existiert (wegen den anderen Fehlern).
Danke für die Hilfe
cu
robertthronhill
Kann mir jemand sagen, wo ich in diesem Script:
PHP-Code:
<?php
error_reporting(E_ALL);
$XMLEntities = array(
'&' => '&',
'<' => '<',
'>' => '>',
//''' => '\'',
'"' => '"'
);
$noteam=0; // Var für Fallabfrage PLAYER_HAS_NO_TEAM
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function startElement(&$parser, &$element_name, &$element_attribute)
{
global $XMLEntities, $idout, $noteam;
print $file;
print "<br>---<br>";
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());
}
}
}
function endElement($parser, $element_name)
{
global $idout,$noteam;
$element_name = strtolower($element_name);
if($element_name == "team")
{
$noteam--;
}
}
$time_start = getmicrotime();
global $file;
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;
print $file;
print "<br>---<br>";
$xmlFile = file($file);
$parser = xml_parser_create('');
xml_set_element_handler($parser, "startElement", "endElement");
foreach($xmlFile as $elem)
{
xml_parse($parser, $elem);
}
xml_parser_free($parser);
//include("process.inc"); // Expat-Processor
}
mysql_close($dbconn);
flush();
?>
Kopievontest.xml
---
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 21
---
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 23
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 21
---
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 23
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 21
---
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 23
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 21
---
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 23
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 48
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(CASH, DEATHS, KILLS, NAME) VALUES ('250', '1', '0', 'stryge')' at line 1
---
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 21
---
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 23
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 21
---
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 23
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 21
---
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 23
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 21
---
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 23
Notice: Undefined variable: file in D:\xampp\htdocs\MightyStats\soldnerstats.php on line 48
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(CASH, DEATHS, KILLS, NAME) VALUES ('250', '1', '0', 'stryge')' at line 1
Danke für die Hilfe
cu
robertthronhill
Kommentar