[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

mysql_set_charset

Posted on 2011-02-23
6
Medium Priority
?
997 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
5 Comments
 
LVL 5

Accepted Solution

by:
maduic earned 1336 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 664 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 1336 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month20 days, 3 hours left to enroll

873 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