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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.