HOWTO: Queries with UFT-8 (or any charset)
Just do a "set names CHARSET-TO-USE;" query before anything... checkout this example:
My apache server is configured to encode everything to utf-8... so is my php... If the example doesn't work AS IT IS... try adding the meta tag for UTF-8 encoding... something like :
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
in the <HEAD> section of your html document...
Checkout this page's (http://dev.mysql.com) source code for a clearer example.
<?php
$MySQL_username = '';
$MySQL_password = '';
$link = mysqli_connect('localhost',$MySQL_username,$MySQL_password,'test');
$queries = array
(
'set names utf8;',
'CREATE TABLE ñoño (name VARCHAR(20), password VARCHAR(20));',
'CREATE TABLE príviledges (admin BOOLEAN, user BOOLEAN, banned BOOLEAN);',
"INSERT INTO ñoño VALUES ('Rénich','ñañañaña');",
"INSERT INTO príviledges VALUES ('1','1','0');",
"SELECT * FROM ñoño,príviledges"
);
foreach ( $queries as $id => $querie )
{
$query = mysqli_query($link,$querie);
if ( $id == '5' )
{
$result = mysqli_fetch_assoc($query);
print "<pre>\n";
print_r($result);
print "</pre>";
}
}
// Eliminate this line if you want to keep the tables...
mysqli_query($link,'DROP TABLES ñoño,príviledges');
mysqli_close($link);
?>