katten
03-17-2006, 01:45 PM
yea well i made a highscore for the players on my server that gets uppdated every 12 hours but i seam to get a error around char
here the code is
<?php
include('../../includes/config.php');
mysql_query("TRUNCATE system_highscore");
// lets start loading all the chars..
$dir = opendir($folderplayer);
while($file = readdir($dir))
{
// checks that the file is a xml file
$temp = explode(".", $file);
if($temp[1] == "xml")
{
$XML = simplexml_load_string(file_get_contents($folderplayer . $file));
if($XML['access'] > 2) continue;
mysql_query("INSERT INTO system_highscore (char,skill,level) VALUES ('" . $XML['name'] . "','level','".$XML['level']."')") or die(mysql_error());
mysql_query("INSERT INTO system_highscore (char,skill,level) VALUES ('" . $XML['name'] . "','maglevel','" . $XML['maglevel'] . "') ") or die(mysql_error());
$i = 0;
$skills = array('fist','club','sword','axe','dist','shield','fishing');
// Loop throw the skills and insert them
foreach($XML->skills->skill as $skill)
{
mysql_query("INSERT INTO system_highscore
(char,skill,level,tries)
VALUES ('" . $XML['name'] . ",'" . $skills[$i] . "','" . $skill['level'] ."','" . $skill['tries'] . "')
") or die(mysql_error());
$i++;
}
}
}
?>
ERROR: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 'char,skill,level) VALUES ('Azkuz','level','30')' at line 1
here the code is
<?php
include('../../includes/config.php');
mysql_query("TRUNCATE system_highscore");
// lets start loading all the chars..
$dir = opendir($folderplayer);
while($file = readdir($dir))
{
// checks that the file is a xml file
$temp = explode(".", $file);
if($temp[1] == "xml")
{
$XML = simplexml_load_string(file_get_contents($folderplayer . $file));
if($XML['access'] > 2) continue;
mysql_query("INSERT INTO system_highscore (char,skill,level) VALUES ('" . $XML['name'] . "','level','".$XML['level']."')") or die(mysql_error());
mysql_query("INSERT INTO system_highscore (char,skill,level) VALUES ('" . $XML['name'] . "','maglevel','" . $XML['maglevel'] . "') ") or die(mysql_error());
$i = 0;
$skills = array('fist','club','sword','axe','dist','shield','fishing');
// Loop throw the skills and insert them
foreach($XML->skills->skill as $skill)
{
mysql_query("INSERT INTO system_highscore
(char,skill,level,tries)
VALUES ('" . $XML['name'] . ",'" . $skills[$i] . "','" . $skill['level'] ."','" . $skill['tries'] . "')
") or die(mysql_error());
$i++;
}
}
}
?>
ERROR: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 'char,skill,level) VALUES ('Azkuz','level','30')' at line 1