What is incorrect in this script?

Discussion in 'PHP' started by fisad, Jul 2, 2008.

  1. #1
    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); 
    	} 
    } 
    ?>
    PHP:
    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
     
    fisad, Jul 2, 2008 IP
  2. Greg Carnegie

    Greg Carnegie Peon

    Messages:
    385
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I am not an expert on XML but did you tried to write:
    <font color="ff0000">
     
    Greg Carnegie, Jul 2, 2008 IP
  3. fisad

    fisad Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank, but this line not in my php script.

    The scrip is for get directory structure and file contens, not for define attributes
     
    fisad, Jul 2, 2008 IP