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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:13:53+00:00 2026-06-05T23:13:53+00:00

I am developing an app with JAVA and PHP. I call to the php

  • 0

I am developing an app with JAVA and PHP.
I call to the php file from the JAVA class, the php executes queries in the ddbb and returns the result. The problem is that it doesn’t return the characters correctly. I want to use UTF-8, I have in the beginning of my php file this:
header(“Content-type: text/html; charset=utf-8”);
but it doesn`t work. If I put a word directly with strange characters, and I do echo, the word appears correctly, but if I took them from the ddbb, it doesn’t.

The functions mb_internal_encoding returns ISO-8859-1 but if I set it to utf-8 doesnt work either

I don’t know if I explained correctly the problem, sorry for my english.

Thanks

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

    You should prefer the following method if you have php 5.3.6+

    $pdo = new PDO("mysql:host=localhost;dbname=world;charset=utf8", 'my_user', 'my_pass');
    

    The reason is that otherwise, string escaping won’t be handled properly. This is important because php still defaults to emulating prepared statements for mysql, so, it very heavily relies on the internal real_escape_string being able to identify the proper character set. Setting the character set via "SET NAMES ..." will not update the internal character set setting that is used by real_escape_string.

    summary: you may be vulnerable to sql injection attacks if you don’t use the above method. I say may, because it depends on the initial and final charsets.

    alternatively, you can configure pdo to not emulate prepared statements.

    reference:
    http://www.php.net/manual/en/mysqlinfo.concepts.charset.php

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

Sidebar

Related Questions

I am developing a Java app that reads all the emails from GMAIL and
I'm developing a java web app on my local PC that uses a file
I am developing an app that has java files and php files. The java
I am developing a java app for nokia s40 mobiles. My jar file increases
I am developing an android app using code from a normal java application. In
I'm having a problem with java sessions. I'm developing a simple web app, where
I'm develping an app that makes queries on reomte databases, using Json and PHP
I'm developing a java app that exports data to CSV files, intended to be
I am developing an iPhone app that would send emoticons from iPhone to server-side.
I'm developing a java app with swing in Windows. The problem is: after pressing

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.