Exoon Posted May 8, 2011 Share Posted May 8, 2011 Hello, If i have a title like "It's Wonderful!" it always gets displayed as "It?s Wonderful!" and the ? is always in a black diamond. How can i get it to show a ' properly? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/235835-showing-a-from-a-mysql-database/ Share on other sites More sharing options...
wildteen88 Posted May 8, 2011 Share Posted May 8, 2011 It seems you have a charset issue. How are you storing your text within your database? Quote Link to comment https://forums.phpfreaks.com/topic/235835-showing-a-from-a-mysql-database/#findComment-1212317 Share on other sites More sharing options...
diptiranjan Posted May 8, 2011 Share Posted May 8, 2011 "It’s Wonderful!" try this Quote Link to comment https://forums.phpfreaks.com/topic/235835-showing-a-from-a-mysql-database/#findComment-1212350 Share on other sites More sharing options...
crtreedude Posted May 8, 2011 Share Posted May 8, 2011 I will second that it is a charset issue. A few useful commands since I just spent 3 days resolving accents in Spanish. $charset = mysql_client_encoding($conn); printf ("current character set is %s\r\n", $charset); This will show you what encoding that your client is using. mysql_set_charset ( 'utf8',$conn); $charset = mysql_client_encoding($conn); printf ("current character set is %s\r\n", $charset); This will set to utf8, and show that it actually happened. Web browsers can show you what encoding you are using on page. Hope this helps. It is worth reading about encoding, character sets, etc. Quote Link to comment https://forums.phpfreaks.com/topic/235835-showing-a-from-a-mysql-database/#findComment-1212369 Share on other sites More sharing options...
cssfreakie Posted May 8, 2011 Share Posted May 8, 2011 thanks for sharing those snippets crtreedude! charsets are indeed a mayor thing to pay attention to. here is something else that could be useful for anyone: a quote from another forum 1. TEXT FILES, SAVE AS: If you are uploading any pages to the server, you should make sure the page content is SAVED AS (option) Unicode (UTF-8, no BOM), rather than the default (probably Latin1). The UTF-8 BOM causes a lot of problems at this time (especially in PHP); so output _without_ the BOM. 2. DYNAMIC SCRIPT: script output: PERL: Instead of the requisite line, print "Content-type: text/html\r\n\r\n"; use the following line: print qq|Content-type: text/html; charset="utf-8"\r\n\r\n|; PHP: Output this header before content output: header("Content-type: text/html; charset='utf-8'"); 3. HTML: On any html pages output by a script, or by a WYSIWYG editor, or rolled by hand, add the meta tag "charset" identifier before opening the title tag. In fact, it should be the first meta tag after the head tag is opened. This method is suppose to force the browser to reparse everything if it wasn't parsing in that character set in the first place. (However, I can't validate that.) In other words, do this: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 4. XML/XHTML: With XML pages, declare the "charset" in the opening line, like: <?xml version="1.0" encoding="utf-8"?> In xhtml documents, I still add in the meta tag from tip #3, above, for good measure. 5. FORM: To assist with properly encoded form input from your guests and members, use the "accept-charset" form attribute, like this: <form method="post" accept-charset="utf-8"> 6. DATABASE: Finally, you may want to set your database default character set to utf-8 if you are storing utf-8 input. by Fran Corpier @ http://www.webhostingtalk.com/showthread.php?t=622439 Quote Link to comment https://forums.phpfreaks.com/topic/235835-showing-a-from-a-mysql-database/#findComment-1212374 Share on other sites More sharing options...
Tonic-_- Posted May 9, 2011 Share Posted May 9, 2011 Like people said it can be due to the charset but if you want to successfully store anything like ' in the database and still prevent SQL attacks you could also use mysql real escape string. Quote Link to comment https://forums.phpfreaks.com/topic/235835-showing-a-from-a-mysql-database/#findComment-1212690 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.