Populating form fields from MySQL when data contains spaces
Posted 06 August 2006 - 08:55 AM
The following is an example of one of the form fields.
<input type="text" name="description" size="50" value=<?php echo $description; ?> />
I've tried testing echo $description outside of the form and it displays the data perfectly.
Just to further clarify, the data in the database may read "This is a great Product" but when I display the form for the web administrator to edit the text, it will just say "This".
Its obviously something very simple - it always is, but i've exhausted all other resources - can anyone help?
Posted 06 August 2006 - 09:00 AM
<input type="text" name="description" size="50" value=one two three />
When the browser goes over the code he doest understand to what the "two three" part belongs, so he ignores it. The solution will be adding quotes. Change your code to the following:
<input type="text" name="description" size="50" value="<?php echo $description; ?>" />
(Notice the qoutes around the value of "value")
(Gone until 20 to November)
Posted 06 August 2006 - 09:15 AM
Thanks very much for that. Like I said, the solution is so simple - especially when you explain it aswell.
This learning curve is steep - but its great fun, and forums like this are invaluable.
Thanks again man.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users