[php][mysql]Select From issues.

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
In my mysql entries, many of the entries contain [enter] characters. (These are also known as /n or newline)


When I pull them from the table, all of the /n are turned into spaces. Does anybody know how I can fix this?


I am currently using mysql_query("SELECT * FROM ...");
 

jeyson65

New Member
Messages
10
Reaction score
0
Points
0
These newline characters are being returned by the query, it's just that the browser ignores them. You need to replace the newline character with a break tag. Both MySQL and PHP have replace functions so here are your options:

1. MySQL - mysql_query("SELECT REPLACE(<column_name>, '\n', '<br />'), column2, ... FROM...")
2. PHP - Once you have the string, call str_replace('\n', '<br />', <text containing newline>).

I didn't actually try this but I've done it in other databases and languages. You may have to escape the '\' character (with an extra '\').

I hope this helps.
 

stainnn

New Member
Messages
2
Reaction score
0
Points
0
maybe you should use php's function nl2br($string_that_contains_newline) - it converts new line to <br /> tag
 
Top