Solved

mysql_set_charset

Posted on 2011-02-23
6
941 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 143

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

861 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