khaos337 Posted July 2, 2010 Share Posted July 2, 2010 I am building a back end for a web application, and I am populating text boxes with information from a MySQL database. Everything works fine except for the description field which when I assign a default value to the text box, only displays the first word in the string and not the entire string. The code is: <input type=\"text\" name=\"description".$x."\" value=".$row[description]."> For example if $row[description] = "This is a description", the text box would only display "This".What's the best way to make this work? Link to comment Share on other sites More sharing options...
Ingolme Posted July 2, 2010 Share Posted July 2, 2010 You don't have quotes around the attribute value, that's the problem.The thing you're printing looks like this: <input type="text" name="description1" value=This is a description> Link to comment Share on other sites More sharing options...
khaos337 Posted July 2, 2010 Author Share Posted July 2, 2010 You don't have quotes around the attribute value, that's the problem.The thing you're printing looks like this:<input type="text" name="description1" value=This is a description> There are no quotes. Remember that since this is a MySQL variable all the calls are in PHP so this is part of an echo command. The only quotes that print are those around the text and name values, non around the default value.to clarify the full code is:<?phpecho "<input type=\"text\" name=\"description".$x."\" value=".$row[description].">";?> Link to comment Share on other sites More sharing options...
End User Posted July 2, 2010 Share Posted July 2, 2010 There are no quotes. Remember that since this is a MySQL variable all the calls are in PHP so this is part of an echo command.You're misunderstanding what Ingolme is saying. He's correct- you need quotes around the entire string in the field value assignment. Link to comment Share on other sites More sharing options...
Ingolme Posted July 2, 2010 Share Posted July 2, 2010 There are no quotes. Remember that since this is a MySQL variable all the calls are in PHP so this is part of an echo command. The only quotes that print are those around the text and name values, non around the default value.You need the quotation marks.If you don't have quotation marks around the attribute value, everything that's follows a space will be considered a different attributeIn the DOM, this element:<input type="text" name="description1" value=This is a description>Looks like this:element: INPUTattributes: attribute "type": text attribute "name": description1 attribute "value": This attribute "is": attribute "a": attribute "description": Link to comment Share on other sites More sharing options...
khaos337 Posted July 2, 2010 Author Share Posted July 2, 2010 You need the quotation marks.If you don't have quotation marks around the attribute value, everything that's follows a space will be considered a different attributeIn the DOM, this element:<input type="text" name="description1" value=This is a description>Looks like this:element: INPUTattributes: attribute "type": text attribute "name": description1 attribute "value": This attribute "is": attribute "a": attribute "description":Sorry... totally misread that post. Been a long day of coding. Link to comment Share on other sites More sharing options...
dink Posted July 2, 2010 Share Posted July 2, 2010 There are no quotes. Remember that since this is a MySQL variable all the calls are in PHP so this is part of an echo command. The only quotes that print are those around the text and name values, non around the default value.to clarify the full code is:<?phpecho "<input type=\"text\" name=\"description".$x."\" value=".$row[description].">";?> I want to make sure I understand this.Basically what you are saying is the closing quote is missing.<?phpecho "<input type=\"text\" name=\"description".$x."\" value=".$row[description].">;?> Trying to get it straight in my head.dink Link to comment Share on other sites More sharing options...
khaos337 Posted July 2, 2010 Author Share Posted July 2, 2010 I want to make sure I understand this.Basically what you are saying is the closing quote is missing.<?phpecho "<input type=\"text\" name=\"description".$x."\" value=\"".$row[description]."\">";?> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.