php - phph mysqli Retrieve special characters from database when using prepared statements -


i converting php script use prepared statements. when grab piece of text database, special characters replaced �.

example:

the database contains following text : test 'éï' test
(verified phpadmnin exists)

if ( $stmt = $mysqli->prepare ( "select act_omschr jag_activiteiten" ) ) {        $stmt->execute();     $stmt->store_result();       $stmt->bind_result ( $dbomschrijving );     $stmt->fetch();      if ( $stmt->num_rows )     {         echo "$dbomschrijving";     }      $stmt->close(); } 

as result following: test ���� test.

any way fix this?

edits :

changed database tables utf8_unicode_ci did not fix issue. combined dda's awnser below did trick.

$mysqli = new mysqli ( $loginurl, $dbusername, $dbpassword, $database );     $mysqli->set_charset ( "utf8" );) 

for same problem pdo use
$bdd=new pdo("mysql:host=$hostname_conn;dbname=$database_conn","$username_conn","$password_conn"); $bdd->exec('set character set utf8');

... database has in utf-8


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -