homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

HTML text box does not display full result

 6:32 am on Feb 12, 2004 (gmt 0)

I am trying to retrieve a value from a MySQL database and display it using PHP in a text box.
When I use <input type="text" value="<?= $value?>"/> only the first part of $value is displayed. Anything after a space is truncated.
If i print $value elsewhere, it prints the whole string correctly.
Can anyone help me with this.



 7:53 am on Feb 12, 2004 (gmt 0)

I'm no expert, but shouldn't you have echo in there?

<input type="text" value="<? echo $value?>"/>


 12:02 pm on Feb 12, 2004 (gmt 0)

Vinaya is using the concise echo format, as detailed at the end of example 1 in the PHP docs [php.net].

I don't know how to solve the problem, though 8)


 1:24 pm on Feb 12, 2004 (gmt 0)

What exactly is '$value'?

Is this not a problem with the double quotes "" in the $value variable ending the input field?

ie. <input value="This "thing" is red"> would get cut off after 'this'.

Use htmlspecialchars...

<input type="text" value="<?= htmlspecialchars($value)?>">


 10:40 pm on Feb 12, 2004 (gmt 0)

I tried using htmlspecialchars, but that doesnt seem to help.
The value of $value is 'Hello there', no double quotes anywhere, only hello is displayed.
I think i need to use a text area instead of a text.
Will tell you the result once i do that.
Thanks for ur suggestions!


 11:44 pm on Feb 12, 2004 (gmt 0)

Well that's very strange because everything looks good to me. Hard to tell if it's the php or the html. What does the generated source code look like? When you print the $value is that right before the input tag?

BTW, you should have a name="something" in the input tag as well.


 11:54 pm on Feb 12, 2004 (gmt 0)

thanks for that reply..i looked at the source code being generated and realised what was going wrong..
<input type="text" name="cardName" size="30" maxlength="50" value=v nat>
i had value=<?$value?> instead of value="<?$value?>"
thats why it was displaying only the first part.
Thanks for the help.


 12:02 am on Feb 13, 2004 (gmt 0)

Cool you got it working! So what you had in your first post is not exactly what you had in your code. Oy!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved