-1

I am saving html data into mysql

like below

<p>&lt;div id=&quot;aaa&quot;&gt;asdadad&lt;/div&gt;</p>
<p>&lt;div id=&quot;aaa&quot;&gt;asdadad&lt;/div&gt;</p>
<div class="something">some data</div>

when showing the html as string in front end using php , it coverts all 3 lines(above) to html content not just string

But I expect the below result

first 2 line as string and 3rd line as html

I used:

html_entity_decode($content_from_db, ENT_QUOTES, 'utf-8');
Konrad Dzwinel
  • 36,825
  • 12
  • 98
  • 105
Aravinthan
  • 487
  • 1
  • 4
  • 7
  • Are you saying that PHP randomly added `

    ` tags to your string, for no reason?

    – cjds Jan 07 '13 at 01:49
  • possible duplicate [see here](http://stackoverflow.com/questions/2122866/how-to-insert-special-character-in-mysql-via-php-and-display-on-html-page) – mamdouh alramadan Jan 07 '13 at 01:50

1 Answers1

0

Don't do anything to the data, just print it straight to the browser. If the data is stored as you say then you will get expected behaviour. If you don't get expected behaviour then either:

  • Data is not stored correctly, view it in MySQL console or a RDBMS
  • You are post-processing data after it is being pulled from DB
Mike
  • 8,767
  • 8
  • 49
  • 103