problems with characters < and >
Moderator: General Moderators
problems with characters < and >
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?
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?
look at htmlentities()
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 -->
<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 -->
There are no quotes around the value of the attribute value.
compare to
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>- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
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) . """; }?> />- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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.