Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:13:45+00:00 2026-06-13T17:13:45+00:00

show variables : character_set_client utf8 character_set_connection utf8 character_set_database utf8 character_set_filesystem binary character_set_results utf8 character_set_server

  • 0

show variables:

character_set_client        utf8
character_set_connection    utf8
character_set_database      utf8
character_set_filesystem    binary
character_set_results       utf8
character_set_server        latin1
character_set_system        utf8
collation_connection        utf8_general_ci
collation_database          utf8_unicode_ci
collation_server            latin1_swedish_ci

Data inserted is UTF-8 and shows correctly in the database, html header is set to utf-8, meta-tag is set to utf-8. All the content on the site (not coming from database) shows correctly), just not the content from the database.

Connection (PDO):

$pdo = new PDO("mysql:host=$hostname;dbname=$database;charset=utf8",$username,$password,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));

So, I assume it has something to do with the output of show variables as it shows that the server’s character set and collation are not utf-8? However, I run other sites on the same local server without any problems. Any idea where I could look to get it right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:13:47+00:00Added an answer on June 13, 2026 at 5:13 pm

    In your PDO connection:

    new PDO(
        "mysql:host=$hostname;dbname=$database;charset=utf8",
                                               ############
        $username, $password, array(
            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
                                             ##############
        )
    );
    

    You are making use of SQL SET NAMES utf8 which is deprecated. You should not use it any longer. And actually you are already making use of the charset parameter in the PDO DSN string which is the recommended way: charset=utf8.

    Just remove the SET NAMES utf8 init command and you should be fine.

    new PDO(
        "mysql:host=$hostname;dbname=$database;charset=utf8",
        $username, $password
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In MySQL, how to change a variable such as character_set_client? mysql> show variables like
i have the variable $a = 5; i want to show it in binary
I know we use {{ }} characters for variables but I want to show
I want to show a variable (which is an image) a certain amount of
I would like to show the value of a variable in a TextView, like
I'm trying to show custom posts that contain a meta variable that matches a
I have a twig variable html . To show it in a twig template
For debug use I want to show the type of a variable in Google
I'm trying to make a ggplot graph wich show the proportions of a variable
Is it possible to filter numbers from the variable. I can show you one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.