Jump to content

[SOLVED] recognize spaces


dadamssg

Recommended Posts

how do i get php/mysql to recognize spaces?..i put the data im storing through a clean and trim function and then output it with nb2lr and stripslashes, but it will only recognize one space...ex.

 

i can type "blah blah b          blah"

 

and it will output

 

"blah blah b blah"

Link to comment
Share on other sites

I know for sure the pre tag recognizes line breaks.  Not 100% about nobr or the css, but I think they just stop whitespace and hyphens from being eligible for line breaks (so in other words, a \n should be recognized). 

 

Just to note: the nobr is netscape proprietary and not an official tag, though most browsers seem to support it (even IE).  Also I don't think earlier versions of IE support the css attribute (I think IE7+ does. Pretty sure IE6 does not).

Link to comment
Share on other sites

It depends on what data type you set your mysql column to.  afaik none of them will strip out extra space internal to your data, but depending on what type you use, it may pad the end of the string with extra space to reach the length you set it to be. For example, If you set it to a column type of fixed width (like char(50)) and you have 20 char string, it will not strip out internal extra spaces, but it will pad the end of the string to make it 50 chars long.  If you have a variable width column type like varchar(50), it will not pad the string.  If you use a binary data type column like blob, it will store it as is (in binary format though).

 

So to make a long story short, you don't really have to worry about what happens to your data when it's going in to sql, except you might have to trim it if you use a fixed length data type.

Link to comment
Share on other sites

its set to text...so yeah i think i just need to output it between the pre tag, i just put some text with multiple spaces and linebreaks into the db and it get stored the same way i put it in, just doesn't output right...so thanks. ill try to the pre tag and hopefully thatll work :)

Link to comment
Share on other sites

yeah...this has nothing to do with spaces but maybe someone could help me with this since i already have a thread open.

 

i have an inbox for messages in a table...and i want to make the subject clickable, but they have the option to leave the subject blank if they have something in the actual message...but if they leave the subject blank...theres nothing to click. so i thought i would try to make the table cell clickable but that didn't work.

 

heres what i got

 

$subject = ucwords($row['subject']);
echo "<td><h3><a href = showmessage.php?ms={$row['messageid']}>{$subject}</a></h3></td>";

 

any ideas?

Link to comment
Share on other sites

You should be able to make it clickable with javascript (yeah, I know, wrong forum):

 

$subject = ucwords($row['subject']);
echo "<td onclick=\"window.location.href = 'showmessage.php?ms={$row['messageid']}';\" style=\"cursor: pointer;\"><h3><a href=\"showmessage.php?ms={$row['messageid']}\">{$subject}</a></h3></td>";

Link to comment
Share on other sites

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.