1

I've a mysql db with some special characters, an input form, some php pages.

  • In my first php page (requestPage) I have the input form.

  • This page sends (through GET) a parameter to an other php page (ResultsPage).

  • At last this php page (ResultsPage) send a query with the parameter to the dbms and shows results.


RequestPage is encoded as utf-8 through

  • meta http-equiv="Content-Type" content="text/html; charset=utf-8

ResultsPage is encoded as utf-8 through

  • meta http-equiv="Content-Type" content="text/html; charset=utf-8
  • header('Content-type: text/html; charset=utf-8');

The database and its tables are encoded as utf8_general_ci.


Now, for instance:

  • if I put in the form of RequestPage the word "Cantu", the resultsPage executes the query and show me every entry of the DB with the word "Cantù" and for me its OK.
  • If I put in the form of RequestPage the word "Cantù", the resultsPage executes the query and show me no rows but I want to see the rows with the word "Cantù"!

Any suggestion?

1
  • Moreover: In ResultsPage I've printed the query that I'm trying to execute and I've putted it in phpMyAdmin and it works. With "Cantù" phpmyadmin show me the correct rows (the rows with the word "Cantù"). Commented Oct 26, 2014 at 15:12

1 Answer 1

1

I've solved the problem with this string added in the php resultsPage file:

mysql_query("SET character_set_results = 'utf8', character_set_client='utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'", $connection);

Obviously it has to be inserted after this string:

$connection = mysql_connect($servername,$username,$dbpassword);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.