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);
?>
Subject
Views
Written By
Posted
HOWTO: Queries with UFT-8 (or any charset)
3719
September 18, 2005 01:17AM
Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.