note 101735 added to function.mysql-set-charset
| From: | andy_keyworth at yahoo dot com | Date: | Fri, 07 Jan 2011 22:54:13 +0000 |
| Subject: | note 101735 added to function.mysql-set-charset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175522@lists.php.net to get a copy of this message | ||
Hi there,
I've actually solved my problem, but I don't know WHY it's solved, and am hoping
someone can explain a couple of things. It has to do with French character encoding, and
mysql_set_charset().
I'm developing a new Web application- nothing too complex: I'm on a Windows machine, using
XAMPP as the server, MySQL 5.1.41 as the database, PHP 5.3.1 as the language version, and
Dreamweaver as the IDE. In the DB, all relevant columns, and the DB, collate at uft-8_general_ci.
I first noticed that DB-extracted data with accented French characters showed up as the
"diamond-?" character instead. So I started searching for answers and got more confused:
the PHP pages were already set to utf-8 for content, as was the database. When I tried applying the
mysql_set_charset() function to fix it, I got error messages saying that "mysql_set_charset()
expects parameter 2 to be resource".... this didn't make sense because the coding was as
follows:
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
mysql_set_charset('utf-8',$dbc);
I also went into the php.ini file to check the character setting- however, it was already commented
out.
Finally, out of frustration I tried setting the page charset to "iso-8859-1", and
amazingly (because it seems to contradict almost everything I'd been reading online) it worked!
So, I'm hoping that someone can explain:
a) why the iso-8859-1 charset fixed the French character problem where utf-8 failed, and
b) why mysql_set_charset() failed to work, and what the resource is that it wants?
Thank you.
----
Server IP: 69.147.83.197
Probable Submitter: 65.92.114.75
----
Manual Page -- http://www.php.net/manual/en/function.mysql-set-charset.php
Edit -- https://master.php.net/note/edit/101735
Del: integrated -- https://master.php.net/note/delete/101735/integrated
Del: useless -- https://master.php.net/note/delete/101735/useless
Del: bad code -- https://master.php.net/note/delete/101735/bad+code
Del: spam -- https://master.php.net/note/delete/101735/spam
Del: non-english -- https://master.php.net/note/delete/101735/non-english
Del: in docs -- https://master.php.net/note/delete/101735/in+docs
Del: other reasons-- https://master.php.net/note/delete/101735
Reject -- https://master.php.net/note/reject/101735
Search -- https://master.php.net/manage/user-notes.php