gple Posted January 30, 2007 Share Posted January 30, 2007 I am passing a variable $name into a text box and have the variable text show up in the box so I can later change it and update a record. When the variable is two words like "PHP Freaks", the only thing that appears in the text box is "PHP" it leaves out the second word. Here is the php code that outputs the text box:echo "Variable: <input name=variable type=text value=". $variable ."><br>";Any ideas. Link to comment https://forums.phpfreaks.com/topic/36328-help-with-variable-being-passed-to-text-box/ Share on other sites More sharing options...
Orio Posted January 30, 2007 Share Posted January 30, 2007 The HTML looks like this (when you enter "PHP Freaks"):[code]<input name=variable type=text value=PHP Freaks>[/code]The browser doesnt understand to what the word "Freaks" belongs to, so it ignores it.So what's the solution? Adding double quotes. It's a good habit to do so:[code]<?phpecho "Variable: <input type=\"text\" name=\"variable\" value=\"".$variable."\">";//or....echo 'Variable: <input type="text" name="variable" value="'.$variable.'">';?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/36328-help-with-variable-being-passed-to-text-box/#findComment-172725 Share on other sites More sharing options...
gple Posted January 30, 2007 Author Share Posted January 30, 2007 thanks a lot, it worked. Link to comment https://forums.phpfreaks.com/topic/36328-help-with-variable-being-passed-to-text-box/#findComment-172729 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.