br3nn4n Posted June 1, 2009 Share Posted June 1, 2009 I've taken this down to the most basic of levels -- inserting the text through PHPMyAdmin. The situation: I have text that was typed in Word, and thus has curly quotes (“ ” etc.). I want to KEEP those curly quotes! They're pretty But when I try to save the text to my database and then return it, I get those not-so-pretty question marks! So I tried doing it through PHPMyAdmin and it did the same thing, but at least in PMA they SHOW AS CURLY QUOTES, and not question marks! I'm doing this in UTF-8, which obviously supports those characters. My database is set to a default connection of UTF-8, my db collation is set to UTF-8, my php.ini is set to default of UTF-8... Now, why, even when I insert them through PMA, don't they come out in a UTF-8 encoded page correctly?!?! I'm really frustrated. Can someone PLEASE shed some light? I just want to be able to save an article to my database and have it come out the way it went in with the curly quotes. I'm begging here TIA Link to comment https://forums.phpfreaks.com/topic/160446-solved-why-do-curly-quotes-not-come-out-right/ Share on other sites More sharing options...
anupamsaha Posted June 1, 2009 Share Posted June 1, 2009 I've taken this down to the most basic of levels -- inserting the text through PHPMyAdmin. The situation: I have text that was typed in Word, and thus has curly quotes (“ ” etc.). I want to KEEP those curly quotes! They're pretty But when I try to save the text to my database and then return it, I get those not-so-pretty question marks! So I tried doing it through PHPMyAdmin and it did the same thing, but at least in PMA they SHOW AS CURLY QUOTES, and not question marks! I'm doing this in UTF-8, which obviously supports those characters. My database is set to a default connection of UTF-8, my db collation is set to UTF-8, my php.ini is set to default of UTF-8... Now, why, even when I insert them through PMA, don't they come out in a UTF-8 encoded page correctly?!?! I'm really frustrated. Can someone PLEASE shed some light? I just want to be able to save an article to my database and have it come out the way it went in with the curly quotes. I'm begging here TIA Seems that the problem is occurring when you save through the PHP code. Am I correct? If yes, can you please check whether there is any intermediate function exists to convert string to its htmlentities before saving to the DB? Link to comment https://forums.phpfreaks.com/topic/160446-solved-why-do-curly-quotes-not-come-out-right/#findComment-846709 Share on other sites More sharing options...
aschk Posted June 1, 2009 Share Posted June 1, 2009 Indeed, going backwards you should be able to verify the data in your database using whatever SQL tools available (MySQL GUI tools perhaps?), but as anu suggests you're probably pushing it through some form of encoding before entering it into your db. My rules for entered content are: 1) Verify input 2) Escape output So in the 1st part "verify" you want to make sure that the information is correct, and that all the things you don't allow are stripped or returned as errors. In the 2nd part "escape" you want to escape all your output so users cannot insert malicious code into your pages. This usually involves using htmlentites on any output data. Link to comment https://forums.phpfreaks.com/topic/160446-solved-why-do-curly-quotes-not-come-out-right/#findComment-846731 Share on other sites More sharing options...
br3nn4n Posted June 1, 2009 Author Share Posted June 1, 2009 Alright, well I'm on a shared host so I don't have access to the mysql console. Maybe I could try this on XAMPP on my linux box and see where it gets me. What's STILL tripping me up is why it inserts correctly into the database and comes out incorrectly. Maybe I have to use "SET names utf-8" ? Just came across that... Link to comment https://forums.phpfreaks.com/topic/160446-solved-why-do-curly-quotes-not-come-out-right/#findComment-846735 Share on other sites More sharing options...
br3nn4n Posted June 1, 2009 Author Share Posted June 1, 2009 I GOT IT!!! It's mysql_query("SET NAMES 'utf8'")!!!! now it works great! Link to comment https://forums.phpfreaks.com/topic/160446-solved-why-do-curly-quotes-not-come-out-right/#findComment-846742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.