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.
[syntax=php]function get_pool($number){
$xml = simplexml_load_file("odds.xml");
$pool = $xml->pool[$number]->currpool;
return $pool;
}[/syntax]
my xml looks like this
[syntax=xhtml]<?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>
[/syntax]
Problem with loading XML
- FrederickGeek8
- Posts: 148
- Joined: Wed Nov 30, 2011 10:31 pm
Re: Problem with loading XML
Sorry I forgot to post the error.
[syntax=text]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 [/syntax]
[syntax=text]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 [/syntax]
Re: Problem with loading XML
Lets start form the first error since the others are probably caused by that.
[syntax=text]Notice: Trying to get property of non-object in /var/www-nerd/coin/functions.inc.php on line 65 [/syntax]
Assuming that line 65 is
[syntax=php]$pool = $xml->pool[$number]->currpool;[/syntax]
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
[syntax=php]var_dump($xml);[/syntax]
and see if the path is as you expect.
[syntax=text]Notice: Trying to get property of non-object in /var/www-nerd/coin/functions.inc.php on line 65 [/syntax]
Assuming that line 65 is
[syntax=php]$pool = $xml->pool[$number]->currpool;[/syntax]
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
[syntax=php]var_dump($xml);[/syntax]
and see if the path is as you expect.