Jump to content

[SOLVED] Display spaces in comments?


limitphp

Recommended Posts

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

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?

 

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.