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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:18:44+00:00 2026-06-02T11:18:44+00:00

Hi i am reading a string written in greek from a site with encoding

  • 0

Hi i am reading a string written in greek from a site with encoding “ISO-8859-7” on a php script running in cmd with the intention of adding parts of it in a mysql database. The problem is that before i add anything to the database i echo and there seems to be an encoding problem. I am attaching the relevant part of code.

$fil1=hitFormGet("http://www.topsites.gr/gr_domain_list/".$site->href);
$fil1=iconv("ISO-8859-7","UTF-8",$fil1);
$html1=str_get_html($fil1);
$data=$html1->find('td class="res3" table tbody table tbody tr');
echo "ttl".$data[4]->plaintext."\n";

and the output is
ttl Φιλοξενεί Site : Îαί

(It appears differently here too…)

  • 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-02T11:18:46+00:00Added an answer on June 2, 2026 at 11:18 am

    Use UTF-8 whenever dealing with PHP and MySQL. Here is how I connect:

    $DB_USERNAME = '';
    $DB_PASSWORD = '';
    $DB_HOST = '';
    $DB_NAME = '';
    
    $pdo_attributes = array();
    $pdo_attributes[PDO::ATTR_EMULATE_PREPARES] = FALSE;
    
    $dsn = sprintf('mysql:dbname=%s;host=%s;charset=utf8', $DB_NAME, $DB_HOST);
    $pdo = new PDO($dsn, $DB_USERNAME, $DB_PASSWORD, $pdo_attributes);
    

    Additionally, in PHP < 5.3.6 set this additional attribute:

    $pdo_attributes[1002] = 'SET NAMES utf8';
    

    The integer 1002 represents PDO::MYSQL_ATTR_INIT_COMMAND, however that command is broken in PHP < 5.3.1.

    Find below the original content of this answer, which is now outdated. This is the way to connect using the old mysql_* functions, which are not recommended any more, with some other gibberish-preventing tips that were necessary at the time:

    mysql_connect ("localhost", "DB_USER", "DB_PASSWORD") or die (mysql_error());
    mysql_select_db ("DATABASE_NAME") or die (mysql_error());
    
    mysql_query("SET character_set_client=utf8"); 
    mysql_query("SET character_set_connection=utf8"); 
    mysql_query("SET character_set_database=utf8"); 
    mysql_query("SET character_set_results=utf8"); 
    mysql_query("SET character_set_server=utf8"); 
    mysql_query("SET NAMES 'utf8'");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does performance for reading/adding values from/to Dictionary(Of String, SomeReferenceType) depend on the number
Im having trouble reading from a CSV file final String DELIMITER = ,; Scanner
ok..so i'm reading from an sqlite db data into a string...it works..but when the
I'm trying to convert a string that I'm reading from a file to lowercase
I have a stream that is reading the response from a site. I am
I have little doubt about string reading in C. string reading functions like gets,
Hi there I'm reading a string and breaking each word and sorting it into
After reading about the problem of passing empty std::string objects between DLLs and EXEs,
I was reading How can I get query string values in JavaScript? on Stackoverflow
I have a simple text reading code for Visual Basic: Dim fileReader As String

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.