fi Posted July 2, 2008 Share Posted July 2, 2008 Hey, I run a php scipt (see down) from my server and the following error is show: The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- A string literal was expected, but no opening quote character was found. Error processing resource 'http://www.fisad.net/ph... <font color=ff0000> ------------^ <?php header( "cache-control: private" ); header( "pragma: no-cache" ); header("Content-Type: text/xml"); $directory = $_GET['str1']; $subapp = $_GET['sub1']; echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"."\n"; echo "<galleries>"."\n"; structure($directory,$directory,$subapp); echo "</galleries>"; $num=1; //function function structure($rootdirpath, $dir, $caller) { //unset($root); if($dp = @opendir($rootdirpath)) { for($i=0;($file=readdir($dp))!==false;$i++) { if ($file !="thumbs") { if (is_dir($rootdirpath."/".$file) && $file != "." && $file != "..") { $src= $rootdirpath."/".$file; $num=$num+1; echo "<gallery number=\"".$num."\" title=\"".$file."\">"."\n"; ExportDirectoryXML($src,$caller); echo "</gallery>"."\n"; structure($rootdirpath."/".$file,$dir,$caller); } } } } closedir($dp); } // function ExportDirectoryXML($base,$subcaller) { if ($dir = @opendir($base)) { while ($file = readdir($dir)) { if ($file{0} != ".") { if (is_dir($base . "/" . $file)) { //ExportDirectoryXML($base . "/" . $file); } else { $ext = @substr($file, (@strrpos($file, ".") ? @strrpos($file, ".") : @strlen($file)), @strlen($file)); $fname = basename($file,$ext); $imgsrc= $base . "/thumbs/" . $file; $src= $base . "/" . $file; if (exif_imagetype($src) != false) { $num=rand()%1000; if ($subcaller !="app"){ $imgsrc= "../../".$imgsrc; $src= "../../".$src; } else { $imgsrc= substr($imgsrc, 3); $src= substr($src, 3); } echo "<image source=\"".$src."\" thumb=\"".$imgsrc."\" descr=\"description\"/>"."\n"; } } } } closedir($dir); } } ?> When I load this script from http://localhost....../php/script.php the result is OK 100%, variables are get from Flex application But when I load from my server, the error is show. I have xampp install localy with php 5.2.5 and my server have support for php 4 and 5. Assets error not in my script file: "<font color=ff0000>" Any help. Thank in advance Link to comment https://forums.phpfreaks.com/topic/112924-what-is-incorrect-in-this-script/ Share on other sites More sharing options...
rhodesa Posted July 2, 2008 Share Posted July 2, 2008 when you open the file on the server, and you see that error, do a View Source. most likely it's a PHP error being thrown and then the XML parser is trying to validate that. what do you see when you do the view source? Link to comment https://forums.phpfreaks.com/topic/112924-what-is-incorrect-in-this-script/#findComment-580095 Share on other sites More sharing options...
fi Posted July 2, 2008 Author Share Posted July 2, 2008 I see: <font color=ff0000> Notice: Undefined index: str1 in /usr/local/pem/vhosts/126956/webspace/httpdocs/php/gallery10.php on line 5 </font><font color=ff0000> Notice: Undefined index: sub1 in /usr/local/pem/vhosts/126956/webspace/httpdocs/php/gallery10.php on line 6 </font><?xml version="1.0" encoding="utf-8"?> <galleries> <font color=ff0000> Warning: closedir(): supplied argument is not a valid Directory resource in /usr/local/pem/vhosts/126956/webspace/httpdocs/php/gallery10.php on line 34 </font></galleries> What happen? Link to comment https://forums.phpfreaks.com/topic/112924-what-is-incorrect-in-this-script/#findComment-580157 Share on other sites More sharing options...
rhodesa Posted July 2, 2008 Share Posted July 2, 2008 that means these values aresn't set: $directory = $_GET['str1']; $subapp = $_GET['sub1']; -Are you supplying the values in the url for str1 and sub1? aka: http://www.hostname.com/php/gallery10.php?str1=something&sub1=foobar -If someone doesn't provide those arguments, what should $directory and $subapp be set to? Or should the script fail? Link to comment https://forums.phpfreaks.com/topic/112924-what-is-incorrect-in-this-script/#findComment-580186 Share on other sites More sharing options...
fi Posted July 2, 2008 Author Share Posted July 2, 2008 Yes, I set from code or browse: http://www.fisad.net/php/gallery10.php?str1=../images&sub1=sub But the same error show: The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- A string literal was expected, but no opening quote character was found. Error processing resource 'http://www.fisad.net/ph... <font color=ff0000> ------------^ You can try with de same line for see the error! Link to comment https://forums.phpfreaks.com/topic/112924-what-is-incorrect-in-this-script/#findComment-580196 Share on other sites More sharing options...
fi Posted July 2, 2008 Author Share Posted July 2, 2008 yeap! I get the problem!!!!! The problem was in Scope of var $num=1, move after line "//unset($root);" and solved!!!! Thank for your help!!!!!! Link to comment https://forums.phpfreaks.com/topic/112924-what-is-incorrect-in-this-script/#findComment-580215 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.