Hi, im really stuck. I passed 2 hours on this now, and i need help.

mySql DB -> ville - utf8_general encoding. Cities added here contains (ÉÀ'-)
php page-> addtown.php - utf8 encoding. Page where users can add Their town if not listed on regusers.php in a SELECT foreach loader.

Here's my code.

REGUSERS.PHP -> This page register users.
and sort cities from MySQL. Cities in the Database has been Manually written with special characters like ÉÀ-'

$sql = mysql_query("select nom from ville order by nom asc");
	while($row = mysql_fetch_array($sql)) {
		foreach($row as $town ) {
			 echo "<option class=\"register_inputs\"value=\"".$town."\">".$town."</option>";	
		}
	} 

Here's, everything is working FINE. Cities showing up like..Montr&#233;al, St-J&#233;rome etc..

ADDTOWN.PHP -> Page where users add their cities.
My problem is, HERE.

	
$town = $_POST['town'];
$check_town = mysql_num_rows(mysql_query("select * from ville where nom ='$town'"));

if($check_town > 0) {
echo "this town exist blabla";

So, when i enter St-j&#233;rome , it never say it exist 🙂
Because when i ask mySql, it send it encoded like St-j&#197;&#234;rome...and mysql return nothing.

Well, resolved..but i don't know why !
If someone could explain why, it would be cool. Thanks

here's the anwser...

	
$town = $_POST['town'];
$check_town = mysql_query("select count(*) from ville where nom ='$town'");

if($check_town > 0) {
echo "this town exist blabla";
    Write a Reply...