tags:

views:

152

answers:

3

Hello, i have this message error and i don't know where does the problem comes from:

<?php include "DBconnection.class.php";

$sql = DBConnection::getInstance(); 

$requete = "my resquest (which is working)";

$sql->query($requete);  

 $xml = '<?xml version="1.0" encoding="UTF-8"?>';
 $xml .='<GamerCertified>';


            while($row = $sql->fetchArray()){

            $moyenne_services =  ($row['services'] + $row['serviceCli']  + $row['interface'] )/3;
            $moyenne_services = round( $moyenne_services,1);

            $moyenne_ge =  ($row['services'] + $row['serviceCli']  + $row['interface'] + $row['qualite'] + $row['rapport'] ) /5;
            $moyenne_ge = round( $moyenne_ge,1);

             $xml .= '<GSP>';

             $xml .= '<nom>'.$row["nom"].'</nom>';

             $xml .= '<votes>'.$row["nb_votes"].'</votes>';

             $xml .= '<services>'.$moyenne_services.'</services>';

             $xml .= '<qualite>'.$row["qualite"].'</qualite>';

             $xml .= '<prix>'.$row["rapport"].'</prix>';

             $xml .= '<transparence>'.$row["transparence"].'</transparence>';

              $xml .= '<moyenneGenerale>'.$moyenne_ge.'</moyenneGenerale>'; 

             $xml .= '<serveursDedies>'.$row["offreDedie"].'</serveursDedies>';

             $xml .= '</GSP>';
        }


 $xml .= '</GamerCertified>';
 echo $xml;

Thanks

(PS: FF /chrome echoes that without tag : bc2x56.99.89.8081ckras1710.09.0080crazy-fun-game11010.010.00100crystal-serv349.79.69.509.60dedicore69.49.38.609.21)

+2  A: 

XML Preamble should be on its own line. Your tag <GamerCertified> is not recognized as a tag.

Just add start the tag on a new line and the error will go away.

EDIT: Please try this,

 $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
 $xml .='<GamerCertified>';
ZZ Coder
i did that but now : Content is not allowed in prolog.. ='(
Tristan
See my edit ...
ZZ Coder
Just tryed it, same error : Content is not allowed in prolog.The file is encoded in UTF-8 without BOM (notepad++) ='(
Tristan
The proper name is XML declaration. And there is no new line character required after it.
Gumbo
A: 

Well, first off, remove the spaces before the opening <?php tag. Second, is that the only file in the script? Are there any non-whitespace characters occurring after the </GamerCertified> tag? If so, that's most likely the issue.

ircmaxell
space between opening and <?php is only present in that post.Plus there is no space after </GamerCertified> tag.
Tristan
+1  A: 

I think the problem is somewhere else. Try using the following code:

$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

instead of:

$xml = '<?xml version="1.0" encoding="UTF-8"?>';

This is because you are storing the whole XML text in a PHP variable, which sometimes go awry.

Also please take care that you don't print any whitespace character before the XML start tag (<?xml...). And just use one carriage return (like the "enter" key of your keyboard) after the XML definition end tag (...encoding="UTF-8"?>), so as to start your XML's first start tag (<GameCertified>).

Hope it helps.

Knowledge Craving