text input and strings with double quotes

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

text input and strings with double quotes

Post by Bill H »

I've done several searches but I'm getting nowhere with this problem. Consider that the user enters the following into a text input in a form:
Person was 6'3" tall, brown eyes, etc.

I have no problem getting that into the database. The problem I have is when the record is called up for review and I attempt to display that string in the text input. The entire string is in the database and in the variable, but all that displays is:
Person was 6'3
This is not a database or PHP question. I have no problems with that part. The question is how do I display in a text input box a string containing a double quote character?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try htmlentitites()

Code: Select all

<?php
$raw = 'ab"<>cd';
$encoded = htmlentities($raw);

echo $encoded;
?>
or (without php) in this case
" -> "
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

Yep, perfect. Thank you.
I knew the gurus on this forum would come up with a tidy answer.
:D
User avatar
thomasd1
Forum Commoner
Posts: 80
Joined: Sat Nov 22, 2003 2:48 pm
Location: Belgium

Post by thomasd1 »

you really don't have to be a guru for that :roll:
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

Didn't say the answer required a guru, merely that the gurus would have it.
Post Reply