0

I have a file containing French words, and I encoded the file as "Latin-1" (uft-8 didn't work), loaded the file to a table in MySQL. I need to $_POST input ("name") from a web page and use the "name" to query from MySQL. My code is as follows:

$name = "d' évaluation perfomance académique";
$sql = "SELECT * FROM application WHERE `Description` = '".$name."'";

For normal "name", it can work. But can't work if the "name" containing (è, d', è).

Any suggestions?

Thanks!

Jason
  • 11
  • 1

1 Answers1

0

Assuming your PHP file is in UTF-8, I believe the following will work:

$name = "d' évaluation perfomance académique";
$sql = "SELECT * FROM application WHERE `Description` = '".$name."'";
$sql_latin1 = iconv("UTF-8","ISO-8859-1",$sql);
Octopus
  • 8,075
  • 5
  • 46
  • 66
  • Please don't answer duplicate questions. – AStopher May 19 '15 at 16:01
  • This solution was not included in that so called duplicate. – Octopus May 19 '15 at 16:08
  • My answer answers this question. While your answer *does* answer this question, it's frowned upon to answer duplicate questions. Both questions deal with character encoding, and both answers are correct. – AStopher May 19 '15 at 16:10
  • Thank you for your advice. But it still can't work. $name = "d' évaluation perfomance académique"; $name_code = iconv("UTF-8","ISO-8859-1",$name); $sql = "SELECT * FROM application WHERE `Description` = '".$name."'"; Still can't get the right result. – Jason May 19 '15 at 16:41