View Full Version : Line failing to break

11-06-2011, 05:32 AM
Does anyone know why I am not getting lines brakes when using \n when inserting the following into a MySQL field?


Old Pedant
11-06-2011, 07:17 AM
Works for me. I did it just with command line, but that shouldn't matter.

mysql> insert into flash values('here is some text\n3/12/2012\nand some more test');
Query OK, 1 row affected (0.02 sec)

mysql> select * from flash;
| s |
| here is some text
and some more test |
1 row in set (0.00 sec)

OH! I think maybe I do know!!!

\n is a newline character in PHP, too! So maybe you need to escape it so it's not treated as such by PHP?

That is ...." . date(DATE_RFC822 . "\\nWRITING ORDER TO DATEBASE\\n" ...

11-06-2011, 02:09 PM
Hi Old Pedant.

I tried braking out with the \\n but it didn't have any effect.
I will continue my investigation and let you know when I find a solution so you can learn it to.

Speak to you soon... I hope. lol

11-06-2011, 02:19 PM
OK, I am back on PHP again and tried this, but fail.

$query = "INSERT INTO orders (events) VALUES ('".date(DATE_RFC822)."\nWRITING ORDER TO DATABASE\n')";

11-06-2011, 03:12 PM
So, it was working all along. I only noticed now when I checked MySQL from terminal. I got it working the way I needed it using the HTML element <PRE>