469,326 Members | 1,359 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

The XML produced by a php is not showing greek

mikek12004
200 100+
I am using this code to produce an xml file, do not pay any attetion to the queries the thing is that even if I put the UTF-8 encoding when I try to run the xml file I get the greek characters as invalid, the crazy thing is that if I open it and press enter somewhere or do any other meaningless change and save it then upload it again it works fine (I have windows XP and the server where the script resides is linux-if that plays any role)
Expand|Select|Wrap|Line Numbers
  1. $file= fopen("player/".$id.".xml", "w");
  2.             //standard headers
  3.             $xml = "<?php xml version=\"1.0\" encoding=\"ISO-8859-7\"?>\n";
  4.             $xml.="<asx version=\"3.0\" >\n";
  5.             $xml.="<title>General Music ASX playlist</title>\n";
  6.             $xml.="<param name=\"encoding\" value=\"utf-8\" />\n";
  7.             $xml.="<moreinfo href=\"http://www.gm.com\"/>\n";
  8.             for ($i=0;$i<$count;$i++)
  9.                 {
  10.                     //get info from database
  11.                     $msg2=explode("/",$msg[$i]);
  12.                     $count2=count($msg2);
  13.                     $code=$msg2[($count2-1)];
  14.                     $pos=strrpos("$code",".");
  15.                         $code=substr($code,0,$pos); //song code
  16.                     $q2= mssql_query("select clroot.Material.description , clroot.item.Code  , clroot.Material.AA ,clroot.item.AA   from (clroot.Material left join clroot.item on clroot.Material.Code=clroot.item.Code) where (  clroot.Material.Code = '$code' )");
  17.                     $r2=mssql_fetch_array($q2);
  18.                     $item2AA=$r2[3];
  19.                     $q3= mssql_query("Select clroot.item.Code from ( clroot.itemrlsn left join clroot.item on clroot.item.AA=clroot.itemrlsn.item2AA ) where(  clroot.itemrlsn.item1AA=$item2AA )");
  20.                     $r3=mssql_fetch_array($q3);
  21.                         $album_code=$r3[0]; //album code
  22.                     $q4=mssql_query("Select Description,BOMAA,Ctgry1,Ctgry2,RecCrD,AltCode,clroot.Material.Code from clroot.material where code='$album_code'");
  23.                     $r4=mssql_fetch_array($q4);
  24.                     $album_description=$r4[0]; //album description
  25.                     $album_BOMAA=$r4[1];
  26.                     $q5=mssql_query("select clroot.Material.Code from (clroot.Material left join clroot.bomLnItm on  clroot.Material.AA=clroot.bomLnItm.MaterialAA) where ( clroot.bomLnItm.BOMCode=$album_BOMAA and clroot.Material.Code >=9.0 and clroot.Material.Code <9.5 and clroot.material.ctgry4!=30)");
  27.                     $r5=mssql_fetch_array($q5);
  28.                     $singer_code=$r5[0];    //singer code
  29.                     $q5=mssql_query("Select descr from clroot.skzoom4 where id='$singer_code'");
  30.                     $r5=mssql_fetch_array($q5);
  31.                     $singer_description=$r5[0];    //singer desc
  32.                     $Qtimi= mssql_query("select retailprice,aa from clroot.material where code='$album_code'");
  33.                     $Rtimi=mssql_fetch_array($Qtimi);
  34.                     $timi1=round("$Rtimi[0]");
  35.                     if ($timi1>$Rtimi[0]) $timi1=$timi1-1;
  36.                     $timi11=stristr("$Rtimi[0]",".");
  37.                     $timi2=substr($timi11,0,3);
  38.                     if ( strlen($timi2)<3 ) $timi2=".00";
  39.                     $timi=$timi1.$timi2; //timi album
  40.                     // create xml entry
  41.                     $xml.="<entry>\n";
  42.                     $display_data=$code."|".$album_code."|".$album_description."|".$singer_code."|".$singer_description."|".$timi."|";
  43.                     $xml.="<title>".$display_data."</title>\n";
  44.                     $xml.="<ref href=\"".$msg[$i]."\" />\n";
  45.                     $xml.="<param name=\"image\" value=\"UserFiles/Image/".$album_code.".jpg\" />\n";
  46.                     $xml.="</entry>\n";
  47.                 }
  48.                 $xml.="</asx>";
  49.             //custom ones here
  50.  
  51.             fwrite($file, $xml);
  52.             fclose($file);
  53.  
an example output with thee above problem is
http://www.***.gr/player/02.xml
and the corresponding xml looks like
Expand|Select|Wrap|Line Numbers
  1. <?php xml version="1.0" encoding="ISO-8859-7"?>
  2. <asx version="3.0" >
  3. <title>General Music ASX playlist</title>
  4. <param name="encoding" value="utf-8" />
  5. <moreinfo href="http://www.gm.com"/>
  6. <entry>
  7. <title>8.01475|1.05059|ΤΑ ΡΕΜΠΕΤΙΚΑ - ΤΑ ΖΕΪΜΠΕΚΙΚΑ ΠΟΥ ΕΓΡΑΨΑΝ ΙΣΤΟΡΙΑ Νο 6|9.00117|ΜΙΧΑΛΗΣ ΔΑΣΚΑΛΑΚΗΣ|8.00|</title>
  8. <ref href="UserFiles/songs/02/8.01475.mp3" />
  9. <param name="image" value="UserFiles/Image/1.05059.jpg" />
  10. </entry>
  11. <entry>
  12. <title>8.01605|2.05008|ΕΠΙΛΟΓΕΣ ΖΕΪΜΠΕΚΙΚΑ|9.00114|ΠΑΝΑΓΙΩΤΗΣ ΜΙΧΑΛΟΠΟΥΛΟΣ|4.40|</title>
  13. <ref href="UserFiles/songs/02/8.01605.mp3" />
  14. <param name="image" value="UserFiles/Image/2.05008.jpg" />
  15. </entry>
  16. <entry>
  17. <title>8.01758|1.05043|Ο ΤΑΣΟΣ ΜΠΟΥΓΑΣ ΣΕ ΤΣΑΚΙΡ ΚΕΦΙ|9.00109|ΤΑΣΟΣ ΜΠΟΥΓΑΣ|8.00|</title>
  18. <ref href="UserFiles/songs/02/8.01758.mp3" />
  19. <param name="image" value="UserFiles/Image/1.05043.jpg" />
  20. </entry>
  21. <entry>
  22. <title>8.01858|1.05060|ΤΑ ΡΕΜΠΕΤΙΚΑ ΤΗΣ ΜΑΓΚΙΑΣ ΚΑΙ ΤΗΣ ΜΑΣΤΟΥΡΑΣ Νο 5|9.00114|ΠΑΝΑΓΙΩΤΗΣ ΜΙΧΑΛΟΠΟΥΛΟΣ|8.00|</title>
  23. <ref href="UserFiles/songs/02/8.01858.mp3" />
  24. <param name="image" value="UserFiles/Image/1.05060.jpg" />
  25. </entry>
  26. <entry>
  27. <title>8.01904|1.05060|ΤΑ ΡΕΜΠΕΤΙΚΑ ΤΗΣ ΜΑΓΚΙΑΣ ΚΑΙ ΤΗΣ ΜΑΣΤΟΥΡΑΣ Νο 5|9.00114|ΠΑΝΑΓΙΩΤΗΣ ΜΙΧΑΛΟΠΟΥΛΟΣ|8.00|</title>
  28. <ref href="UserFiles/songs/02/8.01904.mp3" />
  29. <param name="image" value="UserFiles/Image/1.05060.jpg" />
  30. </entry>
  31. <entry>
  32. <title>8.01937|1.05057|ΤΑ ΡΕΜΠΕΤΙΚΑ - ΦΡΑΓΚΟ ΔΕ Θ' ΑΦΗΣΩ Νο 4|9.00081|ΕΣΚΕΝΑΖΥ ΡΟΖΑ|8.00|</title>
  33. <ref href="UserFiles/songs/02/8.01937.mp3" />
  34. <param name="image" value="UserFiles/Image/1.05057.jpg" />
  35. </entry>
  36. <entry>
  37. <title>8.01950|1.05056|ΤΑ ΡΕΜΠΕΤΙΚΑ - ΣΟΥ ΤΑ 'ΧΩ ΜΑΖΕΜΕΝΑ Νο 1|9.00114|ΠΑΝΑΓΙΩΤΗΣ ΜΙΧΑΛΟΠΟΥΛΟΣ|8.00|</title>
  38. <ref href="UserFiles/songs/02/8.01950.mp3" />
  39. <param name="image" value="UserFiles/Image/1.05056.jpg" />
  40. </entry>
  41. <entry>
  42. <title>8.01964|1.05061|ΤΑ ΡΕΜΠΕΤΙΚΑ - ΑΠ' ΤΗ ΣΜΥΡΝΗ ΣΤΗΝ ΕΛΛΑΔΑ Νο 2|9.00080|ΚΩΣΤΑΣ ΡΟΥΚΟΥΝΑΣ|8.00|</title>
  43. <ref href="UserFiles/songs/02/8.01964.mp3" />
  44. <param name="image" value="UserFiles/Image/1.05061.jpg" />
  45. </entry>
  46. <entry>
  47. <title>8.07834|1.05058|ΤΑ ΡΕΜΠΕΤΙΚΑ - ΕΞΩ ΣΤΕΝΑΧΩΡΙΑ Νο 3|9.00126|ΑΝΘΟΥΛΑ ΑΛΙΦΡΑΓΚΗ|8.00|</title>
  48. <ref href="UserFiles/songs/02/8.07834.mp3" />
  49. <param name="image" value="UserFiles/Image/1.05058.jpg" />
  50. </entry>
  51. <entry>
  52. <title>8.08344|1.04212|ΞΗΜΕΡΩΣΕ ΚΑΙ ΠΑΛΙ ΣΤΟ ΚΑΡΑΒΑΝΙ|9.00045|ΓΙΑΝΝΗΣ ΛΕΜΠΕΣΗΣ|16.00|</title>
  53. <ref href="UserFiles/songs/02/8.08344.mp3" />
  54. <param name="image" value="UserFiles/Image/1.04212.jpg" />
  55. </entry>
  56. <entry>
  57. <title>8.09183|1.05082|ΒΟΤΑΝΑ ΚΑΙ ΚΑΝΑΒΟΥΡΙΕΣ|9.00113|ΠΑΝΟΣ ΑΡΑΒΑΝΙΤΗΣ|8.00|</title>
  58. <ref href="UserFiles/songs/02/8.09183.mp3" />
  59. <param name="image" value="UserFiles/Image/1.05082.jpg" />
  60. </entry>
  61. </asx>
  62.  
any help?
Oct 31 '08 #1
1 3525
Dormilich
8,651 Expert Mod 8TB
you could give utf8_encode() a try if you want to use utf8. then you should declare your xml utf8 too. (but I don't know if it helps, because I don't know which charset your mssql returns)
Oct 31 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Kyle | last post: by
27 posts views Thread by alexdoulou | last post: by
9 posts views Thread by PAN | last post: by
4 posts views Thread by Kiki | last post: by
1 post views Thread by interuser | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.