specials characters not retrieved using uft-8

Problems with the Windows version of XAMPP, questions, comments, and anything related.

specials characters not retrieved using uft-8

Postby blueboy » 08. October 2007 17:58

I used Appserv apache-mysql-php distribution without any problem.

Then I shift to XAMPP, and I have got a problem displaying data that contain á,é,í,ó,ú or ñ from mysql, by using php, so that when I retrieve them from mysql via php I get a kind of ? sign.

My data are stored in mysql and they are setted to utf-8 an so in <meta content> of the *.php doc.

When I write á,é,í,ó,ú or ñ in HTML I get them right, but when I retrieve them from mysql via php I get a kind of ? sign and at least two characters are lost.

Any idea?

Otherwise I have to move back to Appserv...and it has less integrated functions![/list]
blueboy
 
Posts: 4
Joined: 08. October 2007 17:36

Postby Wiedmann » 08. October 2007 18:54

My data are stored in mysql and they are setted to utf-8

What did you mean with this?

I have got a problem displaying data that contain á,é,í,ó,ú or ñ from mysql, by using php, so that when I retrieve them from mysql via php I get a kind of ? sign.

You have told MySQL, that you want the results in UTF-8?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby blueboy » 09. October 2007 09:00

Sorry, for not to be clear, I describe my situation again:

1.- I have data stored in mysql in uft-8 format.

2.- Then I use php to retrieve them .

3.- In my pages the charset is set to uft-8.

4.-An finally, in my pages, when I show data stored in mysql that contain á,é,í,ó,ú or ñ , by using php, I get a kind of ? sign.( Let's say in mysql is stored "camión" and in firefox or explorer I get "cami?n".

5.- And, by the way, if I have in html "camión" firefox or explorer show "camión" without any problem.

6.- And all this did not happen using the AppServ distribution of apache-mysql-php, however I'd like to use XAMPP distribution because it has many more features.
blueboy
 
Posts: 4
Joined: 08. October 2007 17:36

Postby lyntuan » 09. October 2007 10:02

.
Last edited by lyntuan on 26. December 2008 12:51, edited 1 time in total.
AMPstart :: Launch a Portable Web Server
http://ampstart.com
----------------------------------------------------------
Please read Disclaimer section carefully before downloading
lyntuan
 
Posts: 104
Joined: 08. November 2006 00:21

Postby blueboy » 09. October 2007 10:26

Thaks a lot...I'll try it!!!
blueboy
 
Posts: 4
Joined: 08. October 2007 17:36

Postby sari42 » 09. October 2007 15:13

..and to make Geckos feel happy:
header("Content-Type: text/html; charset=utf-8");
sari42
 
Posts: 800
Joined: 27. November 2005 18:28

Problem resolved...thanks to everybody...

Postby blueboy » 09. October 2007 23:17

Here is the solution...

Open you prefered editor...

and open C:\xampp\mysql\bin\my.cnf

And write this (just the bold sentences the other stuff is already written):
my.cnf :
.../

[client]
# password = your_password
port = 3306
socket = mysql

default-character-set = utf8

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
basedir="C:/xampp/mysql"
tmpdir="C:/xampp/tmp"
datadir="C:/xampp/mysql/data"

# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set = utf8
character-set-server = utf8
collation-server = utf8_general_ci
init_connect = 'SET collation_connection = utf8_general_ci'
init_connect = 'SET NAMES utf8'

.../

Then you have to shut down and restart mysql from c:\xampp directory .bat files or to uninstall it as service and then reinstall from c:\xampp\mysql .bat files ( so that you remove c:\windows\my.ini and put the new one).

And if you have the data stored in mysql as utf-8 and in your header also charsert=utf-8..you can use any kind of character at your website without any problem.
blueboy
 
Posts: 4
Joined: 08. October 2007 17:36

Postby Wiedmann » 10. October 2007 00:46

Code: Select all
init_connect = 'SET collation_connection = utf8_general_ci'
init_connect = 'SET NAMES utf8'

This does not work with all MySQL user accounts....

and in your header also charsert=utf-8..

If you provide your HTML pages in UTF-8, you must say to MySQL, that your queries are in UTF-8 and you want the results in UTF-8. (regardless in which charset the data is stored in MySQL). This is done with this query:
Code: Select all
SET NAMES 'UTF8'

(and with this query in your code, this works with all user accounts)

In "my.cnf", that's all you need (if you want UTF-8 as default for new databases/tables):
Code: Select all
[client]
default-character-set=utf8

[mysqld]
default-character-set=utf8

But you can also make UTF-8 databases with the old default "latin1". Just use the CHARSET option in the "CREATE DATABASE" statement.

BTW: PHP don't use the "my.cnf".
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 48 guests