Strange XML/file read problem

From: Date: Thu, 08 Aug 2002 08:57:04 +0000
Subject: Strange XML/file read problem
Groups: php.general 
Request: Send a blank email to php-general+get-111616@lists.php.net to get a copy of this message
I have a strange XML/file reading problem that I can't quite crack. The environment is as follows: PHP 4.1.2 Apache Cobolt Linux C32_III, kernel 2.2.16 The chunk of code is as follows: $fp = fopen($XMLPath . $_REQUEST['system_template'] . ".xml", "r"); if(!$fp) die('Could not read XML data file'); while ($data = fread($fp, 4096)) { xml_parse($parser, $data, feof($fp)) or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser))); } fclose($fp); xml_parser_free($parser); Assume in this case that $XMLPath = '/home/sites/www.mysite.com/web/xml/' and _$REQUEST['system_template'] = 'myxml'. This would give a full path of '/home/sites/www.mysite.com/web/xml/myxml.xml'. Assume that this file exists (because in all cases it does), and that the httpd user has permissions to it (it does, I gave full read/write/execute to everyone, just to eliminate that as a potential problem). Occasionally this will read the XML data without any problem. Most of the time though, it gives the message "XML error: syntax error at line 1". The XML files themselves are fine, I have checked their validity in several programs. The files can obviously be opened, because $fp returns okay. Does PHP do some kind of read level locking I am not aware of, that would cause only a single version of the script to be able to read the XML file at a time? This has me completely stumped. Any help you could offer would be greatly appreciated. Matt Holmes

« previous php.general (#111616) next »