WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-29-2007, 11:19 AM
dak888 dak888 is offline
WebProWorld Member
 

Join Date: Nov 2006
Posts: 72
dak888 RepRank 0
Default Truncated text box - PHP

Hello everyone,

Having a problem with one of my text boxes and the displayed value being truncated.

<input name="Comments" id="Comments" type="text" value="<?php echo htmlspecialchars($row_orderComments['PPassValue']); ?>" />

Text is displayed right up to the first space character and then nothing...

I have several other text boxes on the same page with no issues so I'm a bit perplexed as to why this one is being truncated.

I added the htmlspecialchars after doing some reading but no joy. When I view the source of the page, the entire value is written correctly in the value= field but its not displaying in the text box. There are no size or max char limitations. I've tested it with both fields that may have special characters and one's without any special character but still nothing.

I've also created it so it's not in a form element and it displays just fine. It's just when it's in a text box.

*scratches head*

Any help is appreciated.

Thanks,

DaK
Reply With Quote
  #2 (permalink)  
Old 11-29-2007, 01:05 PM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,647
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: Truncated text box - PHP

Try this: <input name="Comments" id="Comments" type="text" value="<?=htmlspecialchars($row_orderComments['PPassValue'])?>" /> This will remove formatting issues that may result from any PHP syntax. Also, make absolutely sure that the first quotation mark is in the position shown in your sample, and that the htmlspecialchars function is not replacing spaces with &nbsp;
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #3 (permalink)  
Old 11-29-2007, 04:47 PM
dak888 dak888 is offline
WebProWorld Member
 

Join Date: Nov 2006
Posts: 72
dak888 RepRank 0
Default Re: Truncated text box - PHP

Thanks for responding Wige but no joy. Not sure what is going on here.

DaK
Reply With Quote
  #4 (permalink)  
Old 11-29-2007, 05:26 PM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,647
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: Truncated text box - PHP

Can you post what the tag looks like when you view source on the rendered page?
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #5 (permalink)  
Old 11-30-2007, 10:43 AM
dak888 dak888 is offline
WebProWorld Member
 

Join Date: Nov 2006
Posts: 72
dak888 RepRank 0
Default Re: Truncated text box - PHP

Sure,

<td><input name="Comments" id="Comments" type="text" value="ph-LCM
please cut pole 5ft and two pieces of 86 , 3 pieces total." /></td>

In the text box on the page itself, you only see "ph-LCM".

Thanks,

DaK
Reply With Quote
  #6 (permalink)  
Old 11-30-2007, 11:33 AM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,647
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: Truncated text box - PHP

My theory is that a newline is being added somehow, possibly by the special characters function (changing a br to a newline?) or by whatever is putting the value into/getting the value from the database. Text fields do not display anything after a \n or \r, unlike text areas.
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #7 (permalink)  
Old 11-30-2007, 11:36 AM
dak888 dak888 is offline
WebProWorld Member
 

Join Date: Nov 2006
Posts: 72
dak888 RepRank 0
Default Re: Truncated text box - PHP

That is very possible and would probably explain why the other text boxes work fine since there is no possibility of there being line breaks.

Is there a quick way I can sanatize for the line breaks? I'm not that good with regular expressions.

Thanks,

DaK
Reply With Quote
  #8 (permalink)  
Old 11-30-2007, 11:48 AM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,647
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: Truncated text box - PHP

PHP Code:
$row_orderComments['PPassValue'] = ereg_replace("\n"''$row_orderComments['PPassValue']);
$row_orderComments['PPassValue'] = ereg_replace("\r"''$row_orderComments['PPassValue']); 
This will remove both \n and \r. Some systems do line returns with both characters (\r\n) so you need to sanitize for both.
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #9 (permalink)  
Old 11-30-2007, 12:29 PM
dak888 dak888 is offline
WebProWorld Member
 

Join Date: Nov 2006
Posts: 72
dak888 RepRank 0
Default Re: Truncated text box - PHP

Bingo!

Works like a charm. Thanks for bailing me out Wige!

DaK
Reply With Quote
  #10 (permalink)  
Old 12-06-2007, 04:18 AM
canzoni32 canzoni32 is offline
WebProWorld New Member
 

Join Date: Dec 2007
Posts: 4
canzoni32 RepRank 0
Default Re: Truncated text box - PHP

Congrats for you success.
Another variant is to use Css or dhtml for your needs.
__________________
http://www.canzoni32.com - Tutti i testi delle canzoni italiane e straniere
roxette, u2, abba
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cookie Values getting truncated MHenscheid Web Programming Discussion Forum 0 01-14-2005 01:10 PM
Edit text via a text file or word doc? randelld Graphics & Design Discussion Forum 2 08-08-2004 05:07 AM
Google’s Text Only Cached Pages Raises Issues With Alt Text Chris Insider Reports 26 07-09-2004 10:44 PM
Making Text Graphics Available As Text For SEO Purposes Chris Insider Reports 5 07-04-2004 12:33 AM
inserting text into text area button icb01co2 Web Programming Discussion Forum 1 02-13-2004 05:25 PM


Search Engine Friendly URLs by vBSEO 3.0.0