Page 1 of 1
problems with characters < and >
Posted: Mon Nov 13, 2006 10:25 am
by hmsg
I getting a field from a mysql DB the field has emails in the format: name <email>.
I don't have any problems inserting the emails in the DB, but when i making a select to the DB i only get the name, because the email that is inside < > isnt shown, i only get the email if i put it in a textarea box!!!
how can i solve this?
Posted: Mon Nov 13, 2006 10:28 am
by Burrito
Posted: Mon Nov 13, 2006 10:39 am
by hmsg
that don't resolve if i want to show it in a input form! it only works in a <p> </p> tag. how can i put the value that i receveid form the DB and show it on a input box of a form?
Posted: Mon Nov 13, 2006 10:45 am
by volka
Then please show the relevant piece of your script.
Posted: Mon Nov 13, 2006 10:49 am
by hmsg
html:
<input type="text" name="testers" size="80" maxlength="250" <?php if($testers==null) print(" "); else{ echo "value="; echo htmlentities($testers); }?> />
<!-- In the variable testers i have email in 2 diferent formats: name@domain and name <name@domain>
The problem is withn the second format when i have a email in that format in the input box i only see the name all the other stuff after the first '<' is not being shown
but if i use a text area i have no problem with it -->
Posted: Mon Nov 13, 2006 11:17 am
by volka
There are no quotes around the value of the attribute
value.
compare to
Code: Select all
<html>
<head>
<title>quotes test</title>
</head>
<body>
<form method="post" action="action.php">
<div>
<input type="text" name="a" value=abc xyz />
<br />
<input type="text" name="b" value="abc xyz" />
<br />
<input type="text" name="c" value="Jane Doe <janedoe@yaddayad.da" />
<br />
<input type="submit" />
</div>
</form>
</body>
</html>
Posted: Mon Nov 13, 2006 11:29 am
by hmsg
And how can i put the quotes around it?
because is in a echo i've already tried \"htmlentities($testers)\" , but it didn't work. what is the alternative way?

Posted: Mon Nov 13, 2006 11:44 am
by Chris Corbyn
hmsg wrote:And how can i put the quotes around it?
because is in a echo i've already tried "htmlentities($testers)" , but it didn't work. what is the alternative way?

Code: Select all
<input type="text" name="testers" size="80" maxlength="250" <?php if($testers==null) print(" "); else{ echo "value="" . htmlentities($testers) . """; }?> />
Posted: Mon Nov 13, 2006 12:58 pm
by RobertGonzalez
You know, this has happened before to a other people. The reason the email address doesn't show is because the browser is treating the output of <
email@address.tld> as a tag. You are going to have to get the < and > into a < and %gt; before displaying it.