im trying to safe spanish words with accent in my database but it won't work, i have already tried:
1) changing conllation from tables and rows to utf8_spanish_ci
and utf_unicode_ci.
2)adding a header tag with
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
3)adding
header("Content-Type: text/html;charset=utf-8");
in a php tag.
doing this in an xampp server in my laptop will work, but when i upload the database to a login monster server it wont save the accent properly.
edit: this is the connection im using:
private function Connect()
{
//$this->settings = parse_ini_file("settings.ini.php");
try
{
# Read settings from INI file, set UTF8
$this->pdo = new PDO('mysql:host=localhost;dbname=xxxxx;charset=utf8', 'xxxxx', 'xxxxxx', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
# We can now log any exceptions on Fatal error.
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
# Disable emulation of prepared statements, use REAL prepared statements instead.
$this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
# Connection succeeded, set the boolean to true.
$this->bConnected = true;
}
catch (PDOException $e)
{
# Write into log
echo $this->ExceptionLog($e->getMessage());
die();
}
}
Edit:
i can't save accent, it shows like strange characters like á = ??
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…