Need some assistance on PHP error

Started by Alb0, September 19, 2014, 06:41:19 PM

Previous topic - Next topic

Alb0

Hello friends,

I'm receiving some strange errors on my PHP module that parses XML feeds of my game server to display certain data on the forums. It only happens randomly at times, not sure why. I did not write the code, as I had someone else do so. Here's the errors I'm receiving; (I've also attached an image that displays the error code.)

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /usr/www/clerks/public/forums/Sources/Subs-DreamModules.php(98) : eval()'d code:40 Stack trace: #0 /usr/www/clerks/public/forums/Sources/Subs-DreamModules.php(98) : eval()'d code(40): SimpleXMLElement->__construct('') #1 /usr/www/clerks/public/forums/Sources/Subs-DreamModules.php(98): eval() #2 /usr/www/clerks/public/forums/Sources/DreamPortal.php(437): dreamportal_code_content('// Servers to s...', 'PHP', false, Array, Array) #3 [internal function]: dreamPages() #4 /usr/www/clerks/public/forums/index.php(164): call_user_func('dreamPages') #5 {main} thrown in /usr/www/clerks/public/forums/Sources/Subs-DreamModules.php(98) : eval()'d code on line 40
Any help on this would be greatly appreciated!


Alb0

Quote from: BurkeKnight on September 19, 2014, 06:42:22 PM
http://www.simplemachines.org/community/index.php?topic=527981.0;topicseen

Please do not post duplicate topics.

It wasn't a duplicate, I realized it was in the wrong section. I've asked for the other one to be trashed, thus why I made another topic in this section. My apologies

Burke ♞ Knight

Well, here, they are great at moving topics, when asked. :)

For mod Related Questions it is best to ask the mod author. You can find a link to a topic for the mod or a support board on the mod's page in the Mod Site

This may be an issue with the portal's module...

Arantor

The error is telling you that the XML it's receiving is invalid. I can't obviously see why that would be; the XML looks legal to me.

Alb0

That's strange, as the error only comes up every so often. I didn't code it myself, so I know very little about it to be honest, as my knowledge for it is kind of non-existent.

Arantor

Suggestion: replace the offending code with something that logs what's going on.

$xml = new SimpleXMLElement($data);
$xml = get_object_vars($xml);


try
{
$xml = new SimpleXMLElement($data);
$xml = get_object_vars($xml);
}
catch (Exception $e)
{
trigger_error('Invalid XML returned: ' . $data);
return;
}


Then when it happens you should get an error thrown into the log (and a non-fatal one since this is a caught exception not an uncaught one)

Alb0

Receiving the following error when I input that code,

Parse Error: unexpected 'catch' (T_CATCH) on line 43

Arantor

Then I don't know what you've done. That's the correct syntax for a try/catch block.

Alb0

#9
Quote from: Arantor on September 19, 2014, 09:28:00 PM
Then I don't know what you've done. That's the correct syntax for a try/catch block.

Whoops, my mistake, I had made a minor error. All's working fine. Though I'd have to wait until the next time it acts up to receive any errors, which will most likely be in a few or a while.

Arantor

Cool. Lemme know what happens, am curious about this.

Advertisement: