Hello,
I have this problem.
I am trying to display the content of DB in cp1250 on my page, which is in UTF8 and another mySQL database.
I have created my own UDT called php_projekty which is connecting the DB and then echo-ing the result.
------------
mysql_connect('server_name','login','password');
mysql_select_db('test');
$dnes = date("Y-m-d");
$query = "SELECT nazov, cislo, zaciatok, koniec, riesitel, popis, id, radenie FROM projekty where radenie>='$dnes' ORDER BY radenie ASC" ; // Standard query.
$result = mysql_query ($query);
$pocet = mysql_num_rows($result);
{echo 'Rozpracované projekty (', $pocet, ')
';}
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{echo '
', $row[0], '
Projekt č:', $row[1], '
Začiatok riešenia:', $row[2], '
Koniec riešenia: ', $row[3], ', projekt je v realizácii
Zodpovedný riešiteľ:', $row[4], '
>>> viac o projekte
-------------
and the in the content page inserted
{php_projekty}
The problem is, that the special /local/ characters are not showing well and I become lot of ? and so on.
Is it possible to store the table in cp1250 and convert it somehow to utf8?
Thanks a lot
Miro
Show different charset in UTF8 content
Re: Show different charset in UTF8 content
By using this php function: mb_convert_encoding($string, "your-target-encoding", "your-source-encoding");xmas3 wrote: The problem is, that the special /local/ characters are not showing well and I become lot of ? and so on.
Is it possible to store the table in cp1250 and convert it somehow to utf8?
Last edited by gertvdijk on Wed Aug 29, 2007 10:28 pm, edited 1 time in total.
Re: Show different charset in UTF8 content
Thanks a lot, but where should I put it into my code?
Sorry, I am still php newbie...
Sorry, I am still php newbie...
Re: Show different charset in UTF8 content
You should replace every string that you want to be converted with the code I gave you.xmas3 wrote: Thanks a lot, but where should I put it into my code?
So in your case, that would involve all row[number] strings. But your code is quite a mess, actually.
Put this in the while loop, before the echo statement:
Code: Select all
for ($i = 0; $i < 6; $i++){
$row[i] = mb_convert_encoding($row[i], "utf-8", "cp1250");
}
Lol.xmas3 wrote: Sorry, I am still php newbie...
Last edited by gertvdijk on Wed Aug 29, 2007 10:29 pm, edited 1 time in total.
Re: Show different charset in UTF8 content
Thanks, I ve tryied it but it doesnt work.
I get Fatal error: Call to undefined function: mb_convert_encoding()
and the same with iconv() function.
Is it possible that the functions are not activated by the provider?
Miro
I get Fatal error: Call to undefined function: mb_convert_encoding()
and the same with iconv() function.
Is it possible that the functions are not activated by the provider?
Miro
Re: Show different charset in UTF8 content
Yup, that's possible:
Although, mbstring (multibyte string functions extention for php) is default in my installation, afaik. (Debian etch, apach2-mod-php5)
(source)mbstring is a non-default extension. This means it is not enabled by default.
Although, mbstring (multibyte string functions extention for php) is default in my installation, afaik. (Debian etch, apach2-mod-php5)
Re: Show different charset in UTF8 content
You can make a look with a phpinfo().xmas3 wrote: Is it possible that the functions are not activated by the provider?
If it's not activated try to ask your provider. If he cant/wount help you have a reason to move your website
