-2

I'm working on a spanish script:

I have this code in html:

<div class="details"><b>Detalle:</b> acompañado o no de una tableta digitalizadora, te permitirá¡ dar rienda suelta a tu imaginación y conseguir verdaderas obras de arte</div>

I need this output: (to save in Mysql Database)

<div class="details"><b>Detalle:</b> acompañado o no de una tableta digitalizadora, te permitirá dar rienda suelta a tu imaginación y conseguir verdaderas obras de arte</div>

any functions to do it ?

2
  • 2
    Why don't you store it in utf8? What's that second character set you're using? Commented Mar 12, 2013 at 6:50
  • all content in my database is like the html output example explained above :S Commented Mar 12, 2013 at 6:53

2 Answers 2

1

Change your mysql database/ table / column encoding to UTF-8 (and also set the collation to a compatible value).

ALTER TABLE mytable CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE mytable 
MODIFY country CHAR(50) 
CHARACTER SET utf8 COLLATE utf8_general_ci;

Also specify the char set at the PHP side when connecting.

mysql_set_charset('utf8',$conn);
Sign up to request clarification or add additional context in comments.

Comments

0

mysql_real_escape_stringEscapes special characters in a string for use in an SQL statement

But that is not recommended and it's deprecated as of PHP 5.5.0.

Use this method with mysqli or PDO

4 Comments

Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.
This extension is deprecated as of PHP 5.5.0...php.net/manual/en/function.mysql-real-escape-string.php
@Jack Yes, i do know that. I was in the process of updating my answer. :)
@SudipPal Yes, pls check updated/edited answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.