So I've been working on a small, small side project to learn a bit more about PHP database interactions. I bought a small, cheap database of "Inspirational Stories" and set to work on turning it into a web site that no one will ever remember. :P

I've worked out a number of issues so far and learned a fair bit, however, one issue that I can't seem to pinpoint is issues with entities. I'm not entirely sure if this issue is arising from the initial database encoding, or perhaps I'm pulling in the data wrong from the database, or something... I'm not quite sure what's wrong, and on top of it, I don't really know how to pinpoint it.

For an example of what I mean, see here.

Any hints or clues on this would be appreciated. I'm not even sure if I'm using the correct terminology here.

  • This would be better off on SO...
    – Pekka
    Feb 16, 2011 at 17:58
  • It just sorta hit me about a minute after I hit the submit button... lol - Sorry! No wonder I couldn't find what I'm looking for here
    – Aeo
    Feb 16, 2011 at 17:59
  • no problem. I don't know whether moderators can migrate questions to SO? They probably can.
    – Pekka
    Feb 16, 2011 at 18:15
  • Hey i dont mean to screw your website, but i found a big problem in it, try accessing this url: holdonwhat.com/dbac/?story=%3Cscript%3Ealert(%22hola%22)%3C/…
    – guiman
    Feb 16, 2011 at 18:28
  • @guiman Ewww... Well that's no good... More issues to add to the learning pile :S Thank you though!
    – Aeo
    Feb 16, 2011 at 19:04

2 Answers 2


As Pekka said, your are having trouble with the way you declare your page and the way the information is stored in there. My advise, is to always configure your database to deal with utf-8 , but if that is simply not possible (like with MSSqlServer) and need to show correcly formated informacion, try:

uf8_encode($your_string) so this way you ensure codification, but if the characters stored in the database are in UTF16 or Unicode, i dont think you'll be able to parse all of them correctly. Here is a link to the php manual page regarding utf8_encode


You are declaring the page to be UTF-8 encoded:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

but your text contains ISO-8859-1 characters.

Your data is either stored as ISO-8859-1 (latin1) in the source file or database, or your database connection is latin1 encoded (which is the default). Add some more detailed info about your setup to get detailed advice.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.