Solved

mysql_set_charset

Posted on 2011-02-23
6
954 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
if statement malfunction 5 44
Why is my implode function empty 8 42
Code planning methods/tools? 5 55
Secure registration PHP 7 39
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

732 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