had the enclosed script working just fine on my service providers web space (Linux box).
Decided to crate an Apache, PHP, mySQL setup on one of my XP boxes. all seems to be working fine except the script that runs fine on the service providers Linux box doesnt work on my XP box. PHP versions are the same, I've tried to get php.ini as close as possible.
It moans about array indicies.
I'll enclose some error messages and the script.
TIA for any help.
Regards
Jamie
Code: Select all
<?php
include("databaskoppling.php");
$indexnr = 0;
$indexnr2 = 0;
$in_char = 0;
$in_alliance = 0;
$in_crafting = 0;
$indexnr3 = 0;
$indexnr4 = 0;
$indexnr5 = 0;
function startElement($parser, $name, $attrs=''){
global $current_tag, $thenames, $indexnr, $indexnr2, $in_char, $in_alliance, $thealliance, $in_crafting, $thecraft, $indexnr3, $thecraft2, $indexnr4, $theguild, $indexnr5;
$current_tag = $name;
switch($name){
case 'GUILD':
$theguild[$indexnr5]['guildname']=$attrs['NAME'];
$theguild[$indexnr5]['realm']=$attrs['REALM'];
$theguild[$indexnr5]['activechars']=$attrs['ACTIVECHARS'];
$theguild[$indexnr5]['activemembers']=$attrs['ACTIVEMEMBERS'];
$theguild[$indexnr5]['guildrp']=$attrs['GUILDRP'];
$theguild[$indexnr5]['contacturl']=$attrs['CONTACTURL'];
$theguild[$indexnr5]['websiteurl']=$attrs['WEBSITEURL'];
$theguild[$indexnr5]['timestamp']=$attrs['TIMESTAMP'];
$theguild[$indexnr5]['allianceid']=$attrs['ALLIANCE'];
break;
case 'CHARACTER':
$in_char = 1;
$thenames[$indexnr]['name']=$attrs['NAME'];
$forefternamn = explode(' ',$thenames[$indexnr]['name']);
$thenames[$indexnr]['firstname'] = $forefternamn[0];
$thenames[$indexnr]['lastname'] = $forefternamn[1];
$thenames[$indexnr]['laston']=$attrs['LASTON'];
break;
case 'ALLIANCEMEMBER':
$in_alliance = 1;
break;
case 'TOP_CHAR':
$in_crafting2 = 1;
$thecraft2[$indexnr4]['name']=$attrs['NAME'];
$thecraft2[$indexnr4]['point']=$attrs['POINT'];
default:
break;
}
}
function endElement($parser, $name, $attrs=''){
global $current_tag, $in_char, $indexnr, $in_alliance, $indexnr2, $indexnr3, $in_crafting, $in_crafting2, $indexnr4;
switch($name){
case 'GUILD':
$indexnr5++;
break;
case 'CHARACTER':
$indexnr++;
$in_char = 0;
break;
case 'ALLIANCEMEMBER':
$indexnr2++;
$in_alliance = 0;
break;
case 'TOP_CHAR':
$indexnr4++;
$in_crafting2 = 0;
break;
default:
break;
}
}
function characterData($parser, $data){
global $current_tag, $indexnr, $thenames, $in_char, $in_alliance, $indexnr2, $thealliance, $in_crafting, $indexnr3, $thecraft;
if (($in_char == 1) && ($current_tag == 'RACE')) {
$thenames[$indexnr]['race'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'CLASS')) {
$thenames[$indexnr]['class'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'LEVEL')) {
$thenames[$indexnr]['level'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'GUILDRANK')) {
$thenames[$indexnr]['guildrank'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'TOTALRP')) {
$thenames[$indexnr]['totalrp'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'LASTWEEKRP')) {
$thenames[$indexnr]['lastweekrp'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'ANON')) {
$thenames[$indexnr]['anon'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'WEAPONCRAFT')) {
$thenames[$indexnr]['weaponcraft'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'FLETCHING')) {
$thenames[$indexnr]['fletching'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'TAILORING')) {
$thenames[$indexnr]['tailoring'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'SPELLCRAFT')) {
$thenames[$indexnr]['spellcraft'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'ARMORCRAFT')) {
$thenames[$indexnr]['armorcraft'] .= trim($data);
}
if (($in_char == 1) && ($current_tag == 'ALCHEMY')) {
$thenames[$indexnr]['alchemy'] .= trim($data);
}
if (($in_alliance == 1) && ($current_tag == 'ALNAME')) {
$thealliance[$indexnr2]['alname'] .= trim($data);
}
if (($in_alliance == 1) && ($current_tag == 'ALGUILDID')) {
$thealliance[$indexnr2]['alguildid'] .= trim($data);
}
if (($in_alliance == 1) && ($current_tag == 'ALTOTALRP')) {
$thealliance[$indexnr2]['altotalrp'] .= trim($data);
}
}
$xml_file = 'http://camelot-europe.goa.com/herald/servers/Excalibur/guilds/60.xml';
$type = 'UTF-8';
$xml_parser = xml_parser_create($type);
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
xml_set_element_handler($xml_parser, 'startElement','endElement');
xml_set_character_data_handler($xml_parser, 'characterData');
if (!($fp = fopen($xml_file, 'r'))) {
die("Could not open $xml_file for parsing!\n");
}
$xmldata="";
while ($data = fread($fp, 4096)) {
if (!($data = utf8_encode($data))) {
echo 'ERROR'."\n";
}
$xmldata.=$data;
}
if (!xml_parse($xml_parser, $xmldata, true)) {
die("XML error".xml_error_string(xml_get_error_code($xml_parser)));
}
xml_parser_free($xml_parser);
?>
<?php
mysql_query("DELETE FROM members");
mysql_query("DELETE FROM alliance");
for($j=0;$j<$indexnr;$j++)
{
mysql_query("INSERT INTO members (name, firstname, lastname, laston, race, class, level, guildrank, totalrp, lastweekrp, anon, weaponcraft, fletching, tailoring, spellcraft, armorcraft, alchemy) VALUES('".$thenames[$j]['name']."','".$thenames[$j]['firstname']."','".$thenames[$j]['lastname']."','".$thenames[$j]['laston']."','".$thenames[$j]['race']."','".$thenames[$j]['class']."','".$thenames[$j]['level']."','".$thenames[$j]['guildrank']."','".$thenames[$j]['totalrp']."','".$thenames[$j]['lastweekrp']."','".$thenames[$j]['anon']."','".$thenames[$j]['weaponcraft']."','".$thenames[$j]['fletching']."','".$thenames[$j]['tailoring']."','".$thenames[$j]['spellcraft']."','".$thenames[$j]['armorcraft']."','".$thenames[$j]['alchemy']."')");
}
for($k=0;$k<$indexnr2;$k++)
{
$thealliance[$k]['alname'] = str_replace("ö","ö",$thealliance[$k]['alname']);
$thealliance[$k]['alname'] = str_replace("´","´",$thealliance[$k]['alname']);
$thealliance[$k]['alname'] = str_replace("'", "´", $thealliance[$k]['alname']);
mysql_query("INSERT INTO alliance (alname, guildid, totalrp) VALUES('".$thealliance[$k]['alname']."','".$thealliance[$k]['alguildid']."','".$thealliance[$k]['altotalrp']."')") or die(mysql_error());
}
$ourdate = date("Y-m-d H:i:s", time());
$ourdatetime = explode(' ',$ourdate);
for($o=0;$o<=$indexnr5;$o++)
{
$datetime = explode(' ',$theguild[$o]['timestamp']);
mysql_query("INSERT INTO info (guildname, realm, activechars, activemembers, guildrp, contacturl, website, timestamp, alliance, goadate, goatime, ourdate, ourtime) VALUES('".$theguild[$o]['guildname']."','".$theguild[$o]['realm']."','".$theguild[$o]['activechars']."','".$theguild[$o]['activemembers']."','".$theguild[$o]['guildrp']."','".$theguild[$o]['contacturl']."','".$theguild[$o]['websiteurl']."','".$theguild[$o]['timestamp']."','".$theguild[$o]['allianceid']."','".$datetime[0]."','".$datetime[1]."','".$ourdatetime[0]."','".$ourdatetime[1]."')");
}
for($m=0;$m<$indexnr4;$m++)
{
if($c >= 0 && $c < 5)
{
$crafttyp = "fletching";
}
elseif($c >= 5 && $c < 10)
{
$crafttyp = "weaponcraft";
}
elseif($c >= 10 && $c < 15)
{
$crafttyp = "armorcraft";
}
elseif($c >= 15 && $c < 20)
{
$crafttyp = "tailoring";
}
elseif($c >= 20 && $c < 25)
{
$crafttyp = "alchemy";
}
elseif($c >= 25 && $c < 30)
{
$crafttyp = "spellcraft";
}
if($thecraft2[$m]['name'] != "anonymous")
{
mysql_query("UPDATE fom_xml_members set $crafttyp = '".$thecraft2[$m]['point']."' WHERE name = '".$thecraft2[$m]['name']."'");
}
$c++;
}
echo "Done!";
?>Code: Select all
Notice: Undefined offset: 1 in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 32
Notice: Undefined index: race in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 75
Notice: Undefined index: class in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 78
Notice: Undefined index: level in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 81
Notice: Undefined index: guildrank in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 84
Notice: Undefined index: totalrp in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 87
Notice: Undefined index: lastweekrp in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 90
Notice: Undefined index: anon in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 93
Notice: Undefined index: race in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 75
Notice: Undefined index: class in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 78
Notice: Undefined index: level in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 81
Notice: Undefined index: guildrank in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 84
Notice: Undefined index: totalrp in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 87
Notice: Undefined index: lastweekrp in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 90
Notice: Undefined index: anon in C:\Program Files\Apache Group\Apache2\htdocs\guilduppd_runweb.php on line 93
..
Repeats over and over ...