I need to add usernames from Facebook to database and these names have UTF-8 characters like (ą,č,ę,ė,į,š,ų,ū). When I add It to database for example letter š
looks like Å¡
In myPhpAdmin I found table setting to set encoding UTF-8, I did that but the same problem.
I added mysql_set_charset('utf8');
to my code, but this wont helped too. Code now looks like:
<?php
$time = $_POST['time'];
$username = $_POST['userName'];
session_start();
$name = $_SESSION['vardas'];
$times = gmdate('H:m:s', $time);
mysql_set_charset('utf8');
$mysqli = new mysqli("localhost","my_db","pass","my_db");
if ($stmt = $mysqli->prepare("INSERT into eurokos (time, userName) VALUE (?,?) ")) {
$stmt->bind_param('is', $time, $name);
// $stmt->bind_param("s", $username);
$stmt->execute();
if ($stmt->error != '') {
echo ' error:'.$stmt->error;
} else {
echo 'success';
}
$stmt->close();
} else {
echo 'error:'.$mysqli->error;
}
Also this php file converted to UTF-8 encoding, but wont helped.
When I use this code echo "Name: " . $user_profile['name'];
Facebook correctly printing username with normal letters in UTF-8. So problem is with inserting usernames to database.
This I use to send username variable from fb.php to db.php (maybe here I need to use any encoding?)
$name = $user_profile['name'];
session_start();
$_SESSION['vardas'] = $name;
Could you help me? Thanks.