kamasheto Posted January 3, 2007 Share Posted January 3, 2007 HeyI have my form all set up, a wonderful textarea styled beautifully, and everything flows into the database like a charm. I check my database and the message lies right there exactly how I want it. However my problem arises when I call for the information and print it out again.If I pass to the database:"HeyHow are you?"In the database it is stored:"HeyHow are you?"But if I call for it and print out again, it says:"Hey How are you?"Now what am I missing here? Thanks for any feedback :) Link to comment https://forums.phpfreaks.com/topic/32636-solved-mysql-results-inquery/ Share on other sites More sharing options...
corbin Posted January 3, 2007 Share Posted January 3, 2007 Its because it's being stored with \n, and html is rendered with a new line being <br> so you can simply replace \n with <br> with something such as$var = str_replace("\n", "<br>", $var); Link to comment https://forums.phpfreaks.com/topic/32636-solved-mysql-results-inquery/#findComment-151842 Share on other sites More sharing options...
ted_chou12 Posted January 3, 2007 Share Posted January 3, 2007 try storing it like this:[code]"Hey<br>How are you?"[/code]This might work, if it doesnt, tell me, I will give you other ideas, and btw you intro. is quite cool... 8)Ted Link to comment https://forums.phpfreaks.com/topic/32636-solved-mysql-results-inquery/#findComment-151844 Share on other sites More sharing options...
corbin Posted January 3, 2007 Share Posted January 3, 2007 Gah I didnt use code brackets on my post and it put it incorrectly...Anyways when ever you echo the results you could do[code]echo str_replace("\n", "<br>", $var);[/code]and it would automatically replace new line characters with a html line break tag. Link to comment https://forums.phpfreaks.com/topic/32636-solved-mysql-results-inquery/#findComment-151848 Share on other sites More sharing options...
MCP Posted January 3, 2007 Share Posted January 3, 2007 what corbin said, except that there is a built in function [url=http://www.php.net/nl2br]nl2br[/url] which will do just that Link to comment https://forums.phpfreaks.com/topic/32636-solved-mysql-results-inquery/#findComment-151884 Share on other sites More sharing options...
kamasheto Posted January 3, 2007 Author Share Posted January 3, 2007 My internet connection died out on me last night after reading corbin's first post and I came to conclude his second method later on. Thank you very much my problem is now solved.@ MCP; I think I'm going to start using your nl2br function more often from now on, thanks for the heads up. Link to comment https://forums.phpfreaks.com/topic/32636-solved-mysql-results-inquery/#findComment-152023 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.