HOWTO: Queries with UFT-8 (or any charset)
Posted by: Renich Bon Ciric
Date: September 18, 2005 01:17AM

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 ( source code for a clearer example.


$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 "</pre>";

// Eliminate this line if you want to keep the tables...
mysqli_query($link,'DROP TABLES ñoño,príviledges');



Options: ReplyQuote

Written By
HOWTO: Queries with UFT-8 (or any charset)
September 18, 2005 01:17AM

Sorry, you can't reply to this topic. It has been closed.

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.