Welcome to WebmasterWorld Guest from 50.19.53.104

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

HTML text box does not display full result

     

Vinaya

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

10+ Year Member



Hi,
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.
Thanks
Regards,
Vinaya

yowza

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

10+ Year Member



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

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

WibbleWobble

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

10+ Year Member



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)

scumm_bar2

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

10+ Year Member



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)?>">

Vinaya

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

10+ Year Member



Hi,
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!
Vinaya

Timotheos

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

WebmasterWorld Senior Member 10+ Year Member



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.

Vinaya

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

10+ Year Member



Hi,
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.
Vinaya

Timotheos

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

WebmasterWorld Senior Member 10+ Year Member



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

Featured Threads

Hot Threads This Week

Hot Threads This Month