php - Accents and special characters in MySQL -


i have got problem accents , special characters such as: ñ, ç...

i use following code introduce data on mysql db:

$artist = mb_convert_encoding(mb_convert_case($_post["artist"], mb_case_title), "utf-8"); $title = mb_convert_encoding(mb_convert_case($_post["title"], mb_case_title), "utf-8"); $name = mb_convert_encoding(mb_convert_case($_post["name"], mb_case_title), "utf-8");  $query = $db->prepare("insert songs (artist, title, name) values (?, ?, ?)"); $query->execute(array($artist, $title, $name)); 

an example fails (artist of song / title of song / ádam gracia). inserted as:

artist of song / title of song / Ãdam gracia) 

the worst of locally (localhost), works perfectly, on hosting, gives above output. same happens ç, ñ, etc..

i have tried changing encoding options @ php admin, don´t know do...

thank all!

try set charset in connection :

new pdo("mysql:host=$dbhost;dbname=$dbname;charset=utf-8", $dbuser, $dbpass); 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -