Problem with loading XML

Ask about a PHP problem here.
Post Reply
User avatar
FrederickGeek8
Posts: 148
Joined: Wed Nov 30, 2011 10:31 pm

Problem with loading XML

Post by FrederickGeek8 »

I wrote a small PHP program on my Mac and it ran fine. Now if I run it on my main Ubuntu server, it does not work. What did I do wrong? I checked all the permissions.
function get_pool($number){
	$xml = simplexml_load_file("odds.xml");
	$pool = $xml->pool[$number]->currpool;

	return $pool;
}
my xml looks like this
<?xml version="1.0"?>
<stats>
	<pool>
		<currpool>10</currpool>
	    <playerslost>1</playerslost>
	    <players>2</players>
	    <origpool>10</origpool>
	</pool>
	<pool>
		<currpool>25</currpool>
	    <playerslost>1</playerslost>
	    <players>2</players>
	    <origpool>25</origpool>
	</pool>
</stats>
User avatar
FrederickGeek8
Posts: 148
Joined: Wed Nov 30, 2011 10:31 pm

Re: Problem with loading XML

Post by FrederickGeek8 »

Sorry I forgot to post the error.
Notice: Trying to get property of non-object in /var/www-nerd/coin/functions.inc.php on line 65 Notice: Undefined variable: min in /var/www-nerd/coin/dice.php on line 15 Notice: Undefined variable: min in /var/www-nerd/coin/dice.php on line 16 Notice: Undefined variable: min in /var/www-nerd/coin/dice.php on line 15 Notice: Undefined variable: min in /var/www-nerd/coin/dice.php on line 16 Notice: Undefined variable: min in /var/www-nerd/coin/dice.php on line 15 Notice: Undefined variable: min in /var/www-nerd/coin/dice.php on line 16 Your lucky number are: -5 3 3 Loser Notice: Trying to get property of non-object in /var/www-nerd/coin/functions.inc.php on line 23 Notice: Trying to get property of non-object in /var/www-nerd/coin/functions.inc.php on line 25 Notice: Trying to get property of non-object in /var/www-nerd/coin/functions.inc.php on line 27 Notice: Trying to get property of non-object in /var/www-nerd/coin/functions.inc.php on line 29 Notice: Trying to get property of non-object in /var/www-nerd/coin/functions.inc.php on line 31 Notice: Trying to get property of non-object in /var/www-nerd/coin/functions.inc.php on line 51 Notice: Indirect modification of overloaded element of SimpleXMLElement has no effect in /var/www-nerd/coin/functions.inc.php on line 51 Notice: Indirect modification of overloaded element of SimpleXMLElement has no effect in /var/www-nerd/coin/functions.inc.php on line 52 Notice: Indirect modification of overloaded element of SimpleXMLElement has no effect in /var/www-nerd/coin/functions.inc.php on line 53 
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Problem with loading XML

Post by jacek »

Lets start form the first error since the others are probably caused by that.
Notice: Trying to get property of non-object in /var/www-nerd/coin/functions.inc.php on line 65 
Assuming that line 65 is
$pool = $xml->pool[$number]->currpool;
This means that either $xml is not an object or $xml->pool[$number] is not, the second one makes more sense since there are no errors from the load function.

So maybe try adding a
var_dump($xml);
and see if the path is as you expect.
Image
Post Reply