Jump to content

Hard to replace " (double quote) in a string for form


SharkBait

Recommended Posts

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
Link to comment
Share on other sites

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 &quot; instead. to easily accomplish this, just run your string through htmlentities() before outputting it to the browser.

good luck
Link to comment
Share on other sites

[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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.