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 6840911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:54:07+00:00 2026-05-26T23:54:07+00:00

I am trying to create some pages using PHP / MySQL. My database table

  • 0

I am trying to create some pages using PHP / MySQL.

My database table is set to utf8_general_ci and so are the table columns. If I use phpmyadmin and manually insert a page I can type all the € I want and they will be inserted as €. I can display this perfectly too.

However when I am trying to insert a page using mysqli the € will be converted to €

I am not doing any conversions of any kind. If I echo the page column fiels just before I am about to insert the page it still displays the € correctly.

The code:

$connection = new mysqli('localhost', 'root', '', 'some_db');

$query  = 'INSERT INTO page (ID, title, content) VALUES (?, ?, ?)';
$params = array('iss', 'NULL', 'test title', '€ some content');

$stmt = $connection->prepare($query);

call_user_func_array(array($stmt, 'bind_param'), by_ref($params));

$stmt->execute();

The by_ref function only makes a reference, nothing else. All works fine except it gives me a headache when it doesn’t insert € correctly. Maybe it is not the bind_param, but something else. I would however like to know the answer!

Update:

Thanks to Digital Precision I figured out I would have to make sure the connection was going to use ‘utf8’. However I only need to set it when using INSERT or UPDATE as SELECT did give me results back in utf8. Hope this helps someone

  • 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-05-26T23:54:08+00:00Added an answer on May 26, 2026 at 11:54 pm

    PHPMyAdmin may be explicitly setting the connection charset to UTF-8 which is why it may work through the admin interface and not through your script. Check out mysqli::set_charset for more detailed info.

    $connection->set_charset('utf8');
    

    Edit

    Try taking out the call_user_function:

    $connection = new mysqli('localhost', 'root', '', 'some_db');
    
    $query  = 'INSERT INTO page (ID, title, content) VALUES (?, ?, ?)';
    //$params = array('iss', 'NULL', 'test title', '€ some content');
    
    $stmt = $connection->prepare($query);
    
    // Replace this
    //call_user_func_array(array($stmt, 'bind_param'), by_ref($params));
    
    // With this
    $stmt->bind_param('iss', 'NULL', 'test title', '€ some content'); 
    
    $stmt->execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help I am trying to create a PHP form using sqlite3
I am trying to use the googlecharts gem to create some quick charts. Here
I have a basic CMS in PHP/MySQL where content managers can create pages to
I've been trying to create some php code that would let me take input
Hi. I've been trying to create a PHP page using Savant Templating Engine that
I'm trying to create a simple message form using navigateToURL() and PHP mail(). But
I am trying to create a simple web crawler using PHP that is capable
I am trying to create a simple Hit Counter using Kohana3 and PHP. But
I'm trying to create some HtmlHelper extensions and ran into a bit of a
I am trying to create some reusable components in Silverlight2 . The difficulty comes

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.