Solved

mysql_set_charset

Posted on 2011-02-23
6
930 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:Shinesh Premrajan
Shinesh Premrajan 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Creating and Managing Databases with phpMyAdmin in cPanel.
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 look for a specific file type in a local or remote server directory using PHP.

895 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

11 Experts available now in Live!

Get 1:1 Help Now