Jump to content

\n does not work?


neo777ph

Recommended Posts

help.

 

I would like to echo:

<? echo "test\n" . "test2"; ?>

as far as i know the output should be:

test

test2

 

i switched the auto_detect_line_endings into ON..to fix the problem..But it still does not fix the problem..I need the new line for my logging system.

 

please help me.

Link to comment
Share on other sites

To be safe, I would use mysql_real_escape_string() before inserting the data to mysql.  Then you can be sure that ANY character will be correctly stored (any that is supported by the underlying data type that is.  Binary data will need mysql's binary data type, which I forgot the name of.  But \n is still ok for text/varchar data).

Link to comment
Share on other sites

no mater what  OS you use MySQL will store the the newline. It just when you send newline charactersw (\r\n, \r or \n) to a web browser it will just ignore them - They are still there but can only be viewed from source. In order to get the browser to display them you need to use the HTML line breaks (<br />).

 

It best to use nl2br when getting data out of the database, not when inserting it into the database.

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.