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
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
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 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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.