Jump to content

[SOLVED] keep formatting


ngreenwood6

Recommended Posts

I have a form that users can fill out to make an entry into the database. The problem I have is that when it comes out of the database I want it to come out in the same formatting that the user had put it in. for example if they go to the next line to start a new paragraph I want it to show that instead of showing it all on the same line. any help is appreciated.

Link to comment
Share on other sites

you can use.

 

mysql_real_escape_string(); // database security.

or

stripslashes(); // min um database security.

or

trim(); // make sure there no weight spaces.

 

There many more

 

stripslashes provides NO security at all. In fact if used incorrectly it can open security holes.

Link to comment
Share on other sites

I am already using mysql_real_escape_string. I was asking if there was anything to use for the formatting. My question is though, how does it know where to put a new line? If they just enter the text and put in some "enter's"(new lines), how does it know that they did that or is there something that I need to do. From looking into that nl2br it looks like I need to tell it where the \n needs to go. Can someone please clarify and maybe possibly an example?

Link to comment
Share on other sites

When inserting data from form into database, newline characters ( \n \r \n\r ) are stored as their ASCII codes. Nothing you should do with them. It's just when you need to display them in HTML (which doesn't care about newlines), that you need to replace those with proper HTML tag.

If you were to display that data into a textarea, you actually wouldn't need nl2br

Link to comment
Share on other sites

Thanks mchi, went to ur website but there no English words.

 

translate looks good and interesting ur website...

 

Wikipedia may be setup to redirect you depending on what country you are in. But the en. part should make it English by default if I am not mistaken.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.