0

hello i was trying to insert whole html data into database for which i used

$details = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['message'])));

which seem to work fine as before it was giving error as there were extra "" while inserting the html for eg "<p>hello</p>" so by using the above it got inserted by now when i am trying to retrieve the data its not coming in correct format.

can some one point me what to use with <?php echo $row['details']; ?> to get the correct html format

6
  • And where did you find this method of preparing text for database insertion? It's very much exactly the wrong escaping function order. Look into prepared statements. Commented Mar 5, 2013 at 18:45
  • possible duplicate of PHP: Decoding Html Entities or better: stackoverflow.com/questions/6465263/reverse-htmlentities Commented Mar 5, 2013 at 18:46
  • Does the data have to be human readable while in the database? If not, I'd just encode in base64 for storage, then decode from base64 to display it. Commented Mar 5, 2013 at 18:47
  • no the data is not be readable to humans in database lol . but still is there any way to get it in correct format with the functions i used while inserting data into database Commented Mar 5, 2013 at 18:50
  • the suggested links does not give the the result :( Commented Mar 5, 2013 at 18:53

1 Answer 1

1

Don't use stripslashes. because mysql_real_escape_string put / before each quote (" '). when you use stripslashes, it will remove that slashes. so you dont get proper output

Sign up to request clarification or add additional context in comments.

1 Comment

this was really something useful. I removed stripshlases from the input of data and it worked like a charm thanks for saving me to be awake at late night :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.