-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 ?

jose sanchez
  • 51
  • 1
  • 9

2 Answers2

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);
Sumit Bijvani
  • 8,154
  • 17
  • 50
  • 82
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

Vimalnath
  • 6,373
  • 2
  • 26
  • 47
  • 5
    [**Please, don't use `mysql_*` functions in new code**](http://bit.ly/phpmsql). They are no longer maintained [and are officially deprecated](http://j.mp/XqV7Lp). See the [**red box**](http://j.mp/Te9zIL)? Learn about [*prepared statements*](http://j.mp/T9hLWi) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://j.mp/QEx8IB) will help you decide which. If you choose PDO, [here is a good tutorial](http://j.mp/PoWehJ). – Ja͢ck Mar 12 '13 at 06:51
  • This extension is deprecated as of PHP 5.5.0...http://php.net/manual/en/function.mysql-real-escape-string.php – Sudip Pal Mar 12 '13 at 06:52
  • @Jack Yes, i do know that. I was in the process of updating my answer. :) – Vimalnath Mar 12 '13 at 06:54
  • @SudipPal Yes, pls check updated/edited answer – Vimalnath Mar 12 '13 at 06:54