I'm creating a test application and keeping the name of the person who is taking it on a table, along with the answers. The problem lies when I enter the following characters
á é í ó ú ñ
I've tried some methods (like iconv function) but still not working.
//A sample of the code
require('../connect_db.php');
setlocale(LC_ALL,"es_ES");
mysql_query("SET NAMES 'utf8'");
$sql = "SELECT *
FROM database.test";
$result = mysql_query($sql) or die (mysql_error());
$row = mysql_fetch_array($result);
$name = utf8decode($row[1]);
echo mb_detect_encoding($name); //Just to test
echo $name;
The result:
UTF-8 G�mez
Edit: The problem is not on the database. I've manually entered names with these characters with no problem, so it must be the code.