 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
07-04-2009, 03:24 PM
|
#1 (permalink)
|
|
The Wanderer
Join Date: Jul 2009
Posts: 10
Thanks: 1
|
cant work this error out
ok i've been working on a world of warcraft armory parser for achievements and for some reason its showing an error even thou the other pages i have just like this one work fine
CODE:
PHP Code:
#!/usr/bin/php
<?php
// Include phpbb's config for db info
//include("config.php");
echo 'Working...' . '</br>';
/*
roster_gen class posted by D1g1talS0ul on elitistjerks.com
*/
class roster_gen {
const BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";
public $query;
public $server;
public $guild;
public $guildie;
public $page;
public function __construct ( $query, $server, $guild, $guildie, $page ) {
$this->query = $query;
$this->server = $server;
$this->guild = $guild;
$this->guildie = $guildie;
$this->page = $page;
} // end of __construct()
public function pull_xml() {
if( $this->query === 'roster' ) {
$url = 'http://eu.wowarmory.com/guild-info.xml?r=' . $this->server . '&n=' . $this->guild. '&p=' . $this->page;
} elseif( $this->query === 'character' ) {
$url = 'http://eu.wowarmory.com/character-sheet.xml?r=' . $this->server . '&n=' . $this->guildie;
} elseif( $this->query === 'achievements' ) {
$url = 'http://eu.wowarmory.com/character-achievements.xml?r=' . $this->server . '&cn=' . $this->guildie . '&gn=' .
$this->guild . '&c=168';
}
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt ($ch, CURLOPT_USERAGENT, roster_gen::BROWSER);
$url_string = curl_exec($ch);
return simplexml_load_string($url_string);
curl_close($ch);
} // end of pull_xml()
} // end class
$roster = new roster_gen ('roster', 'stormrage', 'heroes+of+warcraft', NULL, 1);
$xml_roster = $roster->pull_xml();
// Change to querying achievements
$roster->query=achievements;
// Set up the member array
$member_data = array();
$id = 0;
foreach ($xml_roster->guildInfo->guild->members->character as $char)
{
if ($char['level'] == 80 && $char['rank'] <= '2' ) {
$roster->guildie = $char['name'];
$xml_char = $roster->pull_xml();
$ach = find_category($xml_char->category);
$a = array();
$a[0] = check_achievement($ach, 0);
$a[1] = check_achievement($ach, 1);
$a[2] = check_achievement($ach, 2);
$a[3] = check_achievement($ach, 3);
$a[4] = check_achievement($ach, 4);
$a[5] = check_achievement($ach, 5);
$member_data[$id] = array(
'name' => $char['name'],
'0' => $a[0],
'1' => $a[1],
'2' => $a[2],
'3' => $a[3],
'4' => $a[4],
'5' => $a[5]
);
// Provide some output that it's doing stuff
echo 'Updated: <b>' . $char['name'] . '</b> ' . $a[0] . '-' . $a[1] . '-' . $a[2] . '-' . $a[3] . '-' . $a[4] . '-' . $a[5] . '</br>';
$id++;
}
}
/*
echo '</br>Inserting values into DB...</br>';
// Connect to the DB
$db = mysql_connect($dbhost, $dbuser, $dbpasswd);
$db_selected = mysql_select_db($dbname, $db);
foreach ($member_data as $member)
{
$name = $member['name'];
$sql = "insert into ach_data2(name, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14)
VALUES ('$name', '$a[0]', '$a[1]', '$a[2]', '$a[3]', '$a[4]', '$a[5]', '$a[6]', '$a[7]', '$a[8]', '$a[9]', '$a[10]', '$a[11]', '$a[12]', '$a[13]', '$a[14]')";
$result = mysql_query($sql);
if(!$result);
echo mysql_error() . "\n";
}
echo 'Database update completed.';
*/
function find_category($xml)
{
foreach($xml->achievement as $ach) {
if($ach['id'] == 576)
return $ach;
}
}
function check_achievement($achievement, $num) {
if($achievement ['dateCompleted'] != NULL)
return 1;
else
if($achievement->criteria[$num]['date'] != NULL)
return 1;
else
return 0;
}
?>
mysql access is disabled until error is fixed,
the error i'm recieving is when i update the script it send me this
HTML Code:
#!/usr/bin/php
Working...</br><br />
<b>Notice</b>: Use of undefined constant achievements - assumed 'achievements' in <b>C:\wamp\www\ulduar.php</b> on line <b>65</b><br />
<br />
<b>Notice</b>: Trying to get property of non-object in <b>C:\wamp\www\ulduar.php</b> on line <b>144</b><br />
<br />
<b>Notice</b>: Trying to get property of non-object in <b>C:\wamp\www\ulduar.php</b> on line <b>144</b><br />
<br />
<b>Notice</b>: Trying to get property of non-object in <b>C:\wamp\www\ulduar.php</b> on line <b>144</b><br />
<br />
<b>Notice</b>: Trying to get property of non-object in <b>C:\wamp\www\ulduar.php</b> on line <b>144</b><br />
<br />
<b>Notice</b>: Trying to get property of non-object in <b>C:\wamp\www\ulduar.php</b> on line <b>144</b><br />
<br />
<b>Notice</b>: Trying to get property of non-object in <b>C:\wamp\www\ulduar.php</b> on line <b>144</b><br />
Updated: <b>Goll</b> 0-0-0-0-0-0</br><br />
and the same for ALL the other things its meant to list too
does anyone know how to rectify this error at all
any help is appreciated
thanks in advance
Talonos
Last edited by talonos : 07-04-2009 at 03:25 PM.
Reason: typo
|
|
|
|
07-04-2009, 03:27 PM
|
#2 (permalink)
|
|
The Wanderer
Join Date: Jul 2009
Posts: 10
Thanks: 1
|
ohh btw this is the sort of content its trying to parse from
Code:
<achievement categoryId="168" dateCompleted="2009-06-15+02:00" desc="Defeat Kel'Thuzad on Normal Difficulty in Naxxramas." icon="inv_trinket_naxxramas06" id="574" points="10" title="Kel'Thuzad's Defeat"/>
<achievement categoryId="168" dateCompleted="2009-06-15+02:00" desc="Defeat every boss in Naxxramas on Normal Difficulty." icon="achievement_dungeon_naxxramas_normal" id="576" points="25" title="The Fall of Naxxramas">
<criteria name="The Arachnid Quarter"/>
<criteria name="The Construct Quarter"/>
<criteria name="The Plague Quarter"/>
<criteria name="The Military Quarter"/>
<criteria name="Sapphiron's Demise"/>
<criteria name="Kel'Thuzad's Defeat"/>
</achievement>
|
|
|
|
07-04-2009, 05:09 PM
|
#3 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
Well, it will fail in trying to parse the data between,
Code:
<criteria name="The Arachnid Quarter"/>
<criteria name="The Construct Quarter"/>
because it's not a in the standard simple xml format.
Code:
<criteria>The Arachnid Quarter</criteria>
<criteria>The Construct Quarter</criteria>
It looks like your going to need to use some advanced simplexml, and add some attributes to parse it correctly.
|
|
|
|
07-04-2009, 05:26 PM
|
#4 (permalink)
|
|
The Wanderer
Join Date: Jul 2009
Posts: 10
Thanks: 1
|
thing is thou this script is the same as my others and they are working fine even with the <criteria issue that u say might be breaking it
|
|
|
|
07-04-2009, 05:51 PM
|
#5 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
Can you post a copy of the HTML source? It will help me pinpoint where in the PHP it's failing.
|
|
|
|
07-04-2009, 06:00 PM
|
#6 (permalink)
|
|
The Wanderer
Join Date: Jul 2009
Posts: 10
Thanks: 1
|
my read file:
PHP Code:
#!/usr/bin/php
<?php
/*
// Include phpbb's config for db info
//include("config.php");
echo 'Working...' . '</br>';
/*
roster_gen class posted by D1g1talS0ul on elitistjerks.com
*/
class roster_gen {
const BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";
public $query;
public $server;
public $guild;
public $guildie;
public $page;
public function __construct ( $query, $server, $guild, $guildie, $page ) {
$this->query = $query;
$this->server = $server;
$this->guild = $guild;
$this->guildie = $guildie;
$this->page = $page;
} // end of __construct()
public function pull_xml() {
if( $this->query === 'roster' ) {
$url = 'http://eu.wowarmory.com/guild-info.xml?r=' . $this->server . '&n=' . $this->guild. '&p=' . $this->page;
} elseif( $this->query === 'character' ) {
$url = 'http://eu.wowarmory.com/character-sheet.xml?r=' . $this->server . '&n=' . $this->guildie;
} elseif( $this->query === 'achievements' ) {
$url = 'http://eu.wowarmory.com/character-achievements.xml?r=' . $this->server . '&cn=' . $this->guildie . '&gn=' .
$this->guild . '&c=168';
}
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt ($ch, CURLOPT_USERAGENT, roster_gen::BROWSER);
$url_string = curl_exec($ch);
return simplexml_load_string($url_string);
curl_close($ch);
} // end of pull_xml()
} // end class
$roster = new roster_gen ('roster', 'stormrage', 'heroes+of+warcraft', NULL, 1);
$xml_roster = $roster->pull_xml();
// Change to querying achievements
$roster->query='achievements';
// Set up the member array
$member_data = array();
$id = 0;
foreach ($xml_roster->guildInfo->guild->members->character as $char)
{
if ($char['level'] == 80 && $char['rank'] <= '3' ) {
$roster->guildie = $char['name'];
$xml_char = $roster->pull_xml();
$ach = find_category($xml_char->category);
$a = array();
$a[0] = check_achievement($ach, 0);
$a[1] = check_achievement($ach, 1);
$a[2] = check_achievement($ach, 2);
$a[3] = check_achievement($ach, 3);
$a[4] = check_achievement($ach, 4);
$a[5] = check_achievement($ach, 5);
$member_data[$id] = array(
'name' => $char['name'],
'0' => $a[0],
'1' => $a[1],
'2' => $a[2],
'3' => $a[3],
'4' => $a[4],
'5' => $a[5]
);
// Provide some output that it's doing stuff
echo 'Updated: <b>' . $char['name'] . '</b> ' . $a[0] . '-' . $a[1] . '-' . $a[2] . '-' . $a[3] . '-' . $a[4] . '-' . $a[5] . '</br>';
$id++;
}
}
/*
echo '</br>Inserting values into DB...</br>';
// Connect to the DB
$db = mysql_connect($dbhost, $dbuser, $dbpasswd);
$db_selected = mysql_select_db($dbname, $db);
foreach ($member_data as $member)
{
$name = $member['name'];
$sql = "insert into ach_data(name, a0, a1, a2, a3, a4, a5)
VALUES ('$name', '$member[0]', '$member[1]', '$member[2]', '$member[3]', '$member[4]', '$member[5]')";
$result = mysql_query($sql);
if(!$result);
echo mysql_error() . "\n";
}
echo 'Database update completed.';
*/
function find_category($xml)
{
foreach($xml->achievement as $ach) {
if($ach['id'] == 576)
return $ach;
}
}
function check_achievement($achievement, $num) {
if($achievement ['dateCompleted'] != NULL)
return 1;
else
if($achievement->criteria[$num]['date'] != NULL)
return 1;
else
return 0;
}
?>
source XML file is
http://eu.wowarmory.com/character-ac...warcraft&c=168
to find the area i might be having problems in the xml file just search for and look between the
Code:
[acheivement][/achievment]
tags, my read file is the ONLY code i use except a few settings in a config which are for mysql only anyways
Code:
function check_achievement($achievement, $num) {
if($achievement ['dateCompleted'] != NULL)
return 1;
else
if($achievement->criteria[$num]['date'] != NULL)
return 1;
else
return 0;
seems to be the area where the problem is and the error its kicking out is
Code:
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Updated: Rabbitpt 0-0-0-0-0-0
|
|
|
|
07-05-2009, 08:00 PM
|
#7 (permalink)
|
|
The Contributor
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
|
Did you now get this working? I clicked your link. In:
Opera - you get a text nightmare.
Firefox - same
IE8 - renders the (ugly) HTML.
You need some more standard tags. Namely the html and body. Or xml...
|
|
|
07-05-2009, 08:03 PM
|
#8 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
The output is XML...
It's gotta be the way you parse the XML. I just can't find it.
|
|
|
|
07-05-2009, 11:55 PM
|
#9 (permalink)
|
|
The Wanderer
Join Date: Jul 2009
Posts: 10
Thanks: 1
|
in IE8 click "view source" to see the xml data and i've still not fixed the error :(
|
|
|
|
07-06-2009, 12:03 AM
|
#10 (permalink)
|
|
The Wanderer
Join Date: Jul 2009
Posts: 10
Thanks: 1
|
i've already got one page that parses that same xml file but a diffrent part and the layout is the exact same with the criteria but that page doesn't have the error at all, but this one is and its really starting to annoying me now as quite a few people cant work it out either even thou theres very little diffrence within the 2 pages, i'll post my working script so u guys can compare and see if u can work it out too
PHP Code:
#!/usr/bin/php
<?php
// Include phpbb's config for db info
//include("config.php");
echo 'Working...' . '</br>';
/*
roster_gen class posted by D1g1talS0ul on elitistjerks.com
*/
class roster_gen {
const BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";
public $query;
public $server;
public $guild;
public $guildie;
public $page;
public function __construct ( $query, $server, $guild, $guildie, $page ) {
$this->query = $query;
$this->server = $server;
$this->guild = $guild;
$this->guildie = $guildie;
$this->page = $page;
} // end of __construct()
public function pull_xml() {
if( $this->query === 'roster' ) {
$url = 'http://eu.wowarmory.com/guild-info.xml?r=' . $this->server . '&n=' . $this->guild. '&p=' . $this->page;
} elseif( $this->query === 'character' ) {
$url = 'http://eu.wowarmory.com/character-sheet.xml?r=' . $this->server . '&n=' . $this->guildie;
} elseif( $this->query === 'achievements' ) {
$url = 'http://eu.wowarmory.com/character-achievements.xml?r=' . $this->server . '&cn=' . $this->guildie . '&gn=' .
$this->guild . '&c=168';
}
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt ($ch, CURLOPT_USERAGENT, roster_gen::BROWSER);
$url_string = curl_exec($ch);
return simplexml_load_string($url_string);
curl_close($ch);
} // end of pull_xml()
} // end class
$roster = new roster_gen ('roster', 'stormrage', 'heroes+of+warcraft', NULL, 1);
$xml_roster = $roster->pull_xml();
// Change to querying achievements
$roster->query='achievements';
// Set up the member array
$member_data = array();
$id = 0;
foreach ($xml_roster->guildInfo->guild->members->character as $char)
{
if ($char['level'] == 80 && $char['name'] != 'chiyome' ) {
$roster->guildie = $char['name'];
$xml_char = $roster->pull_xml();
$ach = find_category($xml_char->category);
$a = array();
$a[0] = check_achievement($ach, 0);
$a[1] = check_achievement($ach, 1);
$a[2] = check_achievement($ach, 2);
$a[3] = check_achievement($ach, 3);
$a[4] = check_achievement($ach, 4);
$a[5] = check_achievement($ach, 5);
$a[6] = check_achievement($ach, 6);
$a[7] = check_achievement($ach, 7);
$a[8] = check_achievement($ach, 8);
$a[9] = check_achievement($ach, 9);
$a[10] = check_achievement($ach, 10);
$a[11] = check_achievement($ach, 11);
$a[12] = check_achievement($ach, 12);
$a[13] = check_achievement($ach, 13);
$a[14] = check_achievement($ach, 14);
$member_data[$id] = array(
'name' => $char['name'],
'0' => $a[0],
'1' => $a[1],
'2' => $a[2],
'3' => $a[3],
'4' => $a[4],
'5' => $a[5],
'6' => $a[6],
'7' => $a[7],
'8' => $a[8],
'9' => $a[9],
'10' => $a[10],
'11' => $a[11],
'12' => $a[12],
'13' => $a[13],
'14' => $a[14]
);
// Provide some output that it's doing stuff
// echo 'Updated: <b>' . $char['name'] . '</b> ' . $a[0] . '-' . $a[1] . '-' . $a[2] . '-' . $a[3] . '-' . $a[4] . '-' . $a[5] . '-' . $a[6] . '-' . $a[7] . '-' . $a[8] . '-' . $a[9] . '-' . $a[10] . '-' . $a[11] . '-' . $a[12] . '-' . $a[13] . '-' . $a[14] . '</br>';
$id++;
}
}
/*
echo '</br>Inserting values into DB...</br>';
// Connect to the DB
$db = mysql_connect($dbhost, $dbuser, $dbpasswd);
$db_selected = mysql_select_db($dbname, $db);
foreach ($member_data as $member)
{
$name = $member['name'];
$sql = "insert into ach_data2(name, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14)
VALUES ('$name', '$member[0]', '$member[1]', '$member[2]', '$member[3]', '$member[4]', '$member[5]', '$member[6]', '$member[7]', '$member[8]', '$member[9]', '$member[10]', '$member[11]', '$member[12]', '$member[13]', '$member[14]')";
$result = mysql_query($sql);
if(!$result);
echo mysql_error() . "\n";
}
echo 'Database update completed.';
*/
function find_category($xml)
{
foreach($xml->achievement as $ach) {
if($ach['id'] == 1658)
return $ach;
}
}
function check_achievement($achievement, $num) {
if($achievement ['dateCompleted'] != NULL)
return 1;
else
if($achievement->criteria[$num]['date'] != NULL)
return 1;
else
return 0;
}
?>
this one works without a problem but the ones in my earlier posts don't 
|
|
|
|
07-06-2009, 04:02 PM
|
#11 (permalink)
|
|
The Wanderer
Join Date: Jul 2009
Posts: 10
Thanks: 1
|
ok i think i worked out my problem, seems that there are diffrent
Code:
</category>
<category>
all over the xml file and i cant find a way to select the diffrent ones so for now ima scrp this script
|
|
|
|
07-13-2009, 11:03 AM
|
#12 (permalink)
|
|
The Wanderer
Join Date: Jul 2009
Posts: 10
Thanks: 1
|
ok if anyone wants to know i got my error resolved
find:
PHP Code:
function find_category($xml)
{
foreach($xml->achievement as $ach) {
if($ach['id'] == 576)
return $ach;
}
}
and replace with:
PHP Code:
function find_category($xml)
{
foreach($xml->category as $cat)
{
foreach($cat->achievement as $ach)
{
if($ach['id'] == 576)
return $ach;
}
}
}
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|