2

I'm using htmlentities() to convert characters like Ç and ® to its character codes. I'm getting the texts from the MYSQL database.

while($row = mysql_fetch_array($array, MYSQL_NUM)){
  echo "<div style='float:left; margin-right:40px;'>
 <div style='width:148px; height:141px; background-image:url(uploads/".$row[0].")'>
   <img src='images/glasscase.png' alt=''/>
 </div>
 <font style='font-size:20px'>".htmlentities($row[1], ENT_QUOTES,"UTF-8")."</font>
 <br/>
 <font style='font-size:14px'>".htmlentities($row[2], ENT_QUOTES, "UTF-8")."</font>
</div>";
}

However $row[2] is returning an empty string when using htmlentities(). Does anyone knows what's wrong?

Thanks!

5
  • What's the exact contents of $row[2]? Commented Oct 7, 2010 at 14:49
  • what is encoding of returned data? I mean what is actual encoding, not supposed one Commented Oct 7, 2010 at 14:54
  • How do you know? And why to use htmlentities at all? Commented Oct 7, 2010 at 15:13
  • Because the data is retrieved from a MYSQL database and I know the encoding from the fields. I have to use it because my customer will enter characters like ®ç˚ª•™¢. Commented Oct 7, 2010 at 15:26
  • utf-8 have them all. no need to encode anything Commented Oct 7, 2010 at 21:45

1 Answer 1

1

Why don't you scrap 'htmlentities' and just use

htmlspecialchars();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.