SharkBait Posted September 5, 2006 Share Posted September 5, 2006 Hi, I'm having troubles with inserting values into an HTML form.This is the value in the databae: "Crikey", look at the size of that thing!To be put into:[code]<input type="text" name="title" value="<?php echo $valueFromDB;">" />[/code]But because Crikey is enclosed with " " it breaks the HTML. How do I fix this? Do I just replace all " with ' ?Thanks Quote Link to comment Share on other sites More sharing options...
Stevis2002 Posted September 5, 2006 Share Posted September 5, 2006 Try putting a / before the "crikey, and a / after the closing quotes Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 5, 2006 Share Posted September 5, 2006 if you're placing the text into an HTML tag, you'll most likely need to change it to HTML entities to get it to display properly. for instance, instead of having double quotes, you'll need to use " instead. to easily accomplish this, just run your string through htmlentities() before outputting it to the browser.good luck Quote Link to comment Share on other sites More sharing options...
SharkBait Posted September 5, 2006 Author Share Posted September 5, 2006 I've tried that and in the input box it only displayed a / with no text.Looking at the source it looks like[code]<td><input type="text" size="20" name="title" value="/"Crikey/" it's a stingray!" /> Title</td>[/code] Quote Link to comment Share on other sites More sharing options...
AdRock Posted September 5, 2006 Share Posted September 5, 2006 I'm sure you should use \ instead of / Quote Link to comment Share on other sites More sharing options...
SharkBait Posted September 5, 2006 Author Share Posted September 5, 2006 I get this:[code]<td><input type="text" size="20" name="title" value="\"Crikey\" it's a stingray!" /> Title</td>[/code]And it displays only a \ in the text box. Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 6, 2006 Share Posted September 6, 2006 [quote author=SharkBait link=topic=106988.msg428832#msg428832 date=1157496795]I get this:[code]<td><input type="text" size="20" name="title" value="\"Crikey\" it's a stingray!" /> Title</td>[/code]And it displays only a \ in the text box.[/quote]did you try what i suggested above? Quote Link to comment Share on other sites More sharing options...
SharkBait Posted September 6, 2006 Author Share Posted September 6, 2006 Sorry Obsidian, didnt see your reply. I will use that. I knew there was a function for the entities but couldn't remember it. Quote Link to comment Share on other sites More sharing options...
AdRock Posted September 6, 2006 Share Posted September 6, 2006 Have you tried using 2 single quotes like here '' It looks like "might work !! Quote Link to comment Share on other sites More sharing options...
SharkBait Posted September 7, 2006 Author Share Posted September 7, 2006 I did what bbsidian suggested and it worked. I was using double quotes and they are now working properly thanks to [code=php:0]htmlentities($blah);[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.