Go Back   Tactical Gamer > General Forums > Hardware & Software Discussion

Hardware & Software Discussion Hardware and Software discussion and troubleshooting. Tweakers and Overclockers welcome!
Don't forget to check out our Video Production sub-forum!

Reply
 
Thread Tools
Old 08-10-2008, 11:02 PM   #1 (permalink)
 
orion808's Avatar
 
Join Date: Nov 2004
Location: Florida, US
Age: 28
Posts: 2,400
Tournaments Joined: 0
Tournaments Won: 0
PHP: XML Reader Question

I am trying to grab certain attributes from an xml page. It works fine on my own desktop comp with a localhost server. When I upload to my website, which uses mySQL, it fails. I am new to php and seem to be stuck because it doesn't output an error.

Here is the code: (this was copy/pasted from somewhere on the net and edited by me to fit my needs)

Code:
$xml = new XMLReader();
    $xml->open($new_link); // Declare and open the xml file
    $xml->setParserProperty(2,true); // This seems a little unclear to me - but it worked :)

    while ($xml->read()) {
		echo 'test1';
        switch ($xml->name) {
        case "name":
            $xml->read();
            $conf["name"] = $xml->value;
			$item_name = $conf["name"]; 
			echo $item_name;
            $xml->read();
            break;
        case "quality":
            $xml->read();
            $conf["quality"] = $xml->value;
			$raw_quality = $conf["quality"];
			if ($raw_quality == 'Common')
				$item_quality = 1;
			elseif ($raw_quality == 'Uncommon')
				$item_quality = 2;
			elseif ($raw_quality == 'Rare')
				$item_quality = 3;
			elseif ($raw_quality == 'Epic')
				$item_quality = 4;
			elseif ($raw_quality == 'Legendary')
				$item_quality = 5;
			else 
				$item_quality = 0;
            $xml->read();
            break;
        case "subclass":
            $xml->read();
            $conf["subclass"] = $xml->value;
			$item_subclass = $conf["subclass"];
			echo $item_subclass;
            $xml->read();
            break;
		case "inventorySlot":
            $xml->read();
            $conf["inventorySlot"] = $xml->value;
			$item_slot = $conf["inventorySlot"]; 
			echo $item_slot;
            $xml->read();
            break;
		case "link":
            $xml->read();
            $conf["link"] = $xml->value;
			$item_link = $conf["link"];
			echo $item_link;
            $xml->read();
            break;
		echo "$xml->read()";
        }
    }

    $xml->close();
After this, my code grabs the new $item_xxxx variables and inserts them into the database. Even if I try to echo the variables after this XML Reader, they won't show. Again, I have no issues on my home computer with localhost server. Is there something I am missing? Or is there abetter way to do this?
__________________

orion808 is offline   Reply With Quote
Old 08-10-2008, 11:06 PM   #2 (permalink)
 
orion808's Avatar
 
Join Date: Nov 2004
Location: Florida, US
Age: 28
Posts: 2,400
Tournaments Joined: 0
Tournaments Won: 0
Re: PHP: XML Reader Question

The user inputs a number, hits submit, the xml reader locates the xml with that number on a certain website. Then it reads it and outputs variables for the php to save.

One thing to note....when on the internet (where it is breaking and not working) it also makes the footer disappear after the user inputs the number and hits submit
__________________

orion808 is offline   Reply With Quote
Old 08-11-2008, 08:32 PM   #3 (permalink)
 
orion808's Avatar
 
Join Date: Nov 2004
Location: Florida, US
Age: 28
Posts: 2,400
Tournaments Joined: 0
Tournaments Won: 0
Re: PHP: XML Reader Question

Quote:
PHP 5 introduced XMLReader, a new class for reading Extensible Markup Language (XML).
Seems I might have an older version. After checking my phpinfo, I have v 4.3.11 through my provider (Yahoo).

I've emailed them, but expecting the classic response of a 'not at this time' attitude. Any suggestions?
__________________


Last edited by orion808; 08-11-2008 at 09:19 PM.
orion808 is offline   Reply With Quote
Old 08-12-2008, 06:13 AM   #4 (permalink)



 
Apophis's Avatar
 
Join Date: Oct 2001
Location: Rhode Island, USA
Age: 36
Posts: 9,105
Tournaments Joined: 0
Tournaments Won: 0
Re: PHP: XML Reader Question

PHP4 is officially end-of-life. Hopefully your provider will upgrade soon.
__________________

Diplomacy is the art of saying "good doggie" while looking for a bigger stick.
Apophis is offline   Reply With Quote
Old 08-12-2008, 08:13 PM   #5 (permalink)
 
orion808's Avatar
 
Join Date: Nov 2004
Location: Florida, US
Age: 28
Posts: 2,400
Tournaments Joined: 0
Tournaments Won: 0
Re: PHP: XML Reader Question

Email response said not now, and not soon....so I'll be looking for another provider. Seems silly too. I'm just learning php and I can see the difference in the two.
__________________

orion808 is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement



All times are GMT -4. The time now is 04:50 PM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
©2004-2008 - Tactical Gamer - All Rights Reserved