limitphp Posted February 9, 2009 Share Posted February 9, 2009 If someone puts several spaces in between words in their comments, I want to display them. I noticed in the comment column in mysql it keeps the spaces, but when I display them on the page, it ignores extra spaces. How do you display spaces from the mysql database column? Also, I'm running htmlspecialchars on the comments before I display them. thanks Link to comment https://forums.phpfreaks.com/topic/144502-solved-display-spaces-in-comments/ Share on other sites More sharing options...
.josh Posted February 9, 2009 Share Posted February 9, 2009 you can wrap it in <pre>...</pre> tags or replace each space with "& nbsp;" (no space) this is not a php question. moved. Link to comment https://forums.phpfreaks.com/topic/144502-solved-display-spaces-in-comments/#findComment-758268 Share on other sites More sharing options...
limitphp Posted February 9, 2009 Author Share Posted February 9, 2009 you can wrap it in <pre>...</pre> tags or replace each space with "& nbsp;" (no space) this is not a php question. moved. I tried replacing each " " with and it didn't work. $comment = str_replace(" "," ",$comment); What are spaces stored as in a database entry? Link to comment https://forums.phpfreaks.com/topic/144502-solved-display-spaces-in-comments/#findComment-758271 Share on other sites More sharing options...
.josh Posted February 9, 2009 Share Posted February 9, 2009 how should I know? I don't have access to your database. Link to comment https://forums.phpfreaks.com/topic/144502-solved-display-spaces-in-comments/#findComment-758274 Share on other sites More sharing options...
limitphp Posted February 9, 2009 Author Share Posted February 9, 2009 how should I know? I don't have access to your database. Nevermind...I had it backwards...it should have been: $comment = str_replace(""," ",$comment); works fine now... I'm sorry, what I should have said is, by default, when you install wamp server, in the mysql databases, lets say you input "a b" into a column in a table. With 5 spaces in between the two letters, what will it store the spaces as? Link to comment https://forums.phpfreaks.com/topic/144502-solved-display-spaces-in-comments/#findComment-758282 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.