Jump to content

Showing a " ' " from a mysql database


Exoon

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.