michaelham Posted July 30, 2009 Share Posted July 30, 2009 I am having a problem when trying to execute a php script using the command line interface in windows. The script executes successfully in Internet Explorere but when I run it in CLI I get the following message. "Trying to get property of non object on line 28". Here is the code snippet. The count() function is on line 28. Any ideas? if(file_exists("METADATA-TABLE.xml")) { $xml = simplexml_load_file("C:\greta05\bin\METADATA-TABLE.xml"); echo "<br />File Exists and loaded<br />"; //print_r($xml); //$title = 'Hello'; $p_cnt = count($xml->METADATA->{'METADATA-TABLE'}); echo "<br />There are $p_cnt tables in this metadata.<br />"; Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted July 30, 2009 Share Posted July 30, 2009 "Trying to get property of non object" means you are using -> on a variable that is not an object. Since you are using $xml->METADATA that means $xml is not an object like you expected it to be. Why wouldn't it be an object you ask? Because simplexml_load_file() probably returns FALSE when it fails. Why would simplexml_load_file() fail you ask? Because the file you told it to open doesn't exist. And why doesn't it exist? Because you didn't escape your backslashes in the string. $xml = simplexml_load_file("C:\\greta05\\bin\\METADATA-TABLE.xml"); Quote Link to comment Share on other sites More sharing options...
michaelham Posted July 30, 2009 Author Share Posted July 30, 2009 PERFECT Thank you. Works great now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.