Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
    
This would be better off on SO... –  Pekka 웃 Feb 16 '11 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 '11 at 17:59
    
no problem. I don't know whether moderators can migrate questions to SO? They probably can. –  Pekka 웃 Feb 16 '11 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 '11 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 '11 at 19:04
add comment

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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