Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.