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

  • Home
  • SEARCH
  • 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 7806133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:26:11+00:00 2026-06-02T02:26:11+00:00

I am using PDO for MySQL database connection, selecting, updating and deleting. But I

  • 0

I am using PDO for MySQL database connection, selecting, updating and deleting.

But I have a problem with selecting rows with special characters, for instance, I want to select a page title with ‘Judge-Fürstová Mila’,

Table page,

id    title                     content
1     Judge-Fürstová Mila       xxx

SQL,

SELECT *
FROM page
WHERE title = 'Judge-Fürstová Mila'

Returns result if I query via phpmyadmin.

But it return 0 with PDO,

$sql = ' SELECT *
    FROM page
    WHERE title = ?';

$items = $connection->fetch_assoc($sql,'Judge-Fürstová Mila');

Below is my db class,

class database_pdo
{
    # database handler
    protected $connection = null;

    # make a connection
    public function __construct($dsn,$username,$password)
    {
        try 
        {
            # MySQL with PDO_MYSQL  
            $this->connection = new PDO($dsn, $username, $password);
            $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
        }
        catch (PDOException $e) 
        {
            # call the get_error function
            $this->get_error($e);
        }
    }

    # don't forget to add getter method to get $this->connection, it's just a good practice.
    public function get_connection()
    {
        return $this->connection;
    }

    public function fetch_assoc($query, $params = array())
    {
        try
        {
            # prepare the query
            $stmt = $this->connection->prepare($query);

            # if $params is not an array, let's make it array with one value of former $params
            if (!is_array($params)) $params = array($params);

            # execute the query
            $stmt->execute($params);

            # return the result
            return $stmt->fetch();
        }
        catch (PDOException $e) 
        {
            # call the get_error function
            $this->get_error($e);
        }

    }

Have I missed something in my db class or something else?

  • 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-02T02:26:13+00:00Added an answer on June 2, 2026 at 2:26 am

    Try to add charset=UTF-8 in your $dsn, and change

    $this->connection = new PDO($dsn, $username, $password);
    

    to

    $this->connection = new PDO($dsn, $username, $password, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
    

    I believe it is that SET NAMES utf8 thingie, at least it was in my case

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run this simple SELECT query using PDO::MySQL, but it does
I have been trying to connect to my database using pdo on godaddy with
I am using PDO in PHP and a MySQL database. What I want to
Hi im using PDO to update some fields of a MySQL database. I've written
I'm using the following php pdo code to insert data into mysql database, the
I am trying to place cleaned form data into a MySQL database using PDO.
Strange issue - I have a live copy of a database class (using PDO)
I am having a problem with a website, connecting to a MySQL database using
I have all my sites built on php and mysql stack using PDO. I
I'm using PDO to connect to a mysql database. I'm confused as to where

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.