Solved

mysql_set_charset

Posted on 2011-02-23
6
925 Views
Last Modified: 2012-05-11
Hi

i have a Flex based frontend , php backend and mysql database. I have noticed that ordinarily when i save data to database all special characters like ü ä ß ö Ü Ä é ã get saved oddly (whther its a latin1 default set or utf8 default set for database)

But when i use mysql_set_charset('utf8'); the characters are entered correctly into database.

Is there any way to set the DEFAULT char set for all connections rather than doing this on per connection basis ?

thanks
sid
0
Comment
Question by:young_buddha
6 Comments
 
LVL 5

Accepted Solution

by:
maduic earned 334 total points
ID: 34967480
why not just add mysql_set_charset to the file you're including for db connections?  This way it will run for every page that includes / uses the connection.

If you're using an oop database class, you can add mysql_set _charset to its constructor.
0
 
LVL 17

Assisted Solution

by:shinuq
shinuq earned 166 total points
ID: 34967496
Create the database like :

CREATE DATABASE `databasename` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Then the tables like

CREATE TABLE `dummy`.`dbname` (
`id` INT NOT NULL ,
`name` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`addr` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;


Hope this helps
0
 
LVL 5

Assisted Solution

by:maduic
maduic earned 334 total points
ID: 34967505
@shinuq I believe the database and tables are set up properly, it's the PHP functions which are sending data that is not utf8.

Is this correct young_buddha?
0
 

Author Comment

by:young_buddha
ID: 34967916
it seems that ways, maduic. All default values i have already kept as utf8 for database, I think the flex app. is sending non utf-8 values.

i am already including it in the common include file, but just thought maybe wld be better if it can be set by default for each connection rather than doing it on per connection basis.

thanks
sid
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 37313411
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now