0
<?php
$insert =  "I want to store Å Ä Ö in my database";

mysql_query(" INSERT INTO test (text) VALUE ('$insert')") or die(mysql_error());
?>

Just by using this piece of code, the database stopped storing data as fast as a special symbol (Å Ä Ö) was encountered so in this case I would only find the string "I want to store " in my database table. However I tried to put:

<?php
mysql_query("SET NAMES 'utf8'") or die(mysql_error()); 
mysql_query("SET CHARACTER SET 'utf8'") or die(mysql_error()); 
?>

before the INSERT script, it worked somewhat better but now the issue is that all the special symbols are replaced with question marks ( ? ) in the database tables. My table collation is utf8_swedish_ci. The meta, charset is UTF-8.

Alien13
  • 558
  • 3
  • 8
  • 30
  • 1
    Don't use mysql_* functions, they are deprecated and will be removed in a future version of PHP. – Jocelyn Jul 22 '14 at 22:59
  • 2
    [**See this article**](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) on SO, it may help. – Funk Forty Niner Jul 22 '14 at 23:09
  • 2
    @EugenRieck your comments have meant that any useful comments like Fred's comment are now drowned in useless chatter between you and Jocelyn. Jocelyn - Eugen is right, and if you have to post the standard "deprecated blah blah" then at least put some proper references in so the OP can follow it up easily. – scrowler Jul 22 '14 at 23:23
  • I feel it's prudent as software professionals to offer advice where we see a knowledge deficit. There's far too many bad examples of using the *mysql* extension, including StackOverflow questions. New developers continue to find this information therefore there's nothing wrong with providing a comment around deprecated libraries. That being said, I agree with @scrowler, references should be provided. I like to use [this question and subsequent answers](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) as my canonical source. – Phil Jul 22 '14 at 23:54

0 Answers0