2

I have a problem with encoding.

A friend gave me his php/mysql project to check out. (db, tables, src -> utf8)

I have created and imported his stuff as utf8. Everything was fine until I added a new table to database. Then while encoding php<->mysql crushed, also things I didn't touch.(phpmyadmin still display good values, browser still utf8)

The solution was adding to my.ini file the following lines:

character-set-server=utf8
collation-server=utf8_general_ci

My friend made the same changes on his system, but we made a little test and another friend did the same as I had (adding a table) and it was fine without modifying .ini file.

My question is where potentially could the problem be?

It's important to me because some other friends want the same changes and I'd like to implement this without having them all alter their my.ini files.

2
  • mysql_set_charset(); is the preferred way to do it Commented Feb 8, 2012 at 15:58
  • Just this: mysql_query("SET NAMES utf8"); Commented Mar 13, 2012 at 13:24

1 Answer 1

3

Try this function in connection

mysql_query("SET CHARACTER SET utf8");

or

<?php
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
mysql_query("SET character_set_results=utf8");
?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.