Jump to content

[SOLVED] Yet another XML / PHP Question : Problem Encoding


alxhere

Recommended Posts

Hey,

 

hope somebody can help me here cause i can't figure out what i'm doing wrong!

 

So following situation:

I'm trying to export a xml file from a mySQL Database being handled by Joomla 1.5 CMS.

Connecting to the database, exporting the Data from the MySQL tables to a simple PHP Script and creating

a XML File is not a problem, everything is running fine. Bear in mind that the content of the DB Tables is in greek.

 

I generate the XML file using fopen ('main.xml','w' ) then store all the data in a string and use fwrite($fmain,$str) to write the data in the xml file. Problem is that the content i get from the MySQL Tables appears as '? ? ? ? ?' (Questionmarks) in the xml file.

 

The weird thing about this is that :

$str="äääööööΛΑσδκαλσκδα" appears normally in the XML File , the problem occurs only when i make a MySQL query and assign the transferred values to the string..

 

The encoding of the db is UTF8_general_ci, the encoding of the XML File UTF8 as well...

 

I hope somebody understood what i just said! :P

 

Thanks for your time,

 

alex 

Hey,

 

hope somebody can help me here cause i can't figure out what i'm doing wrong!

 

So following situation:

I'm trying to export a xml file from a mySQL Database being handled by Joomla 1.5 CMS.

Connecting to the database, exporting the Data from the MySQL tables to a simple PHP Script and creating

a XML File is not a problem, everything is running fine. Bear in mind that the content of the DB Tables is in greek.

 

I generate the XML file using fopen ('main.xml','w' ) then store all the data in a string and use fwrite($fmain,$str) to write the data in the xml file. Problem is that the content i get from the MySQL Tables appears as '? ? ? ? ?' (Questionmarks) in the xml file.

 

The weird thing about this is that :

$str="äääööööΛΑσδκαλσκδα" appears normally in the XML File , the problem occurs only when i make a MySQL query and assign the transferred values to the string..

 

The encoding of the db is UTF8_general_ci, the encoding of the XML File UTF8 as well...

 

I hope somebody understood what i just said! :P

 

Thanks for your time,

 

alex

 

For whom it may concern  (i saw that a lot of people faced the same problem)

 

Solution:

--------

After connecting to the Database use

mysql_query("SET NAMES utf8")

 

All encoding problems will disappear :P

 

cheers!!

alex

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.