note 101735 rejected from function.mysql-set-charset by danbrown
| From: | danbrown@php.net | Date: | Fri, 07 Jan 2011 23:23:21 +0000 |
| Subject: | note 101735 rejected from function.mysql-set-charset by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175523@lists.php.net to get a copy of this message | ||
Note Submitter: andy_keyworth at yahoo dot com
----
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.