<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.mysqli-set-charset"> <refnamediv> <refname>mysqli_set_charset</refname> <refname>mysqli->set_charset</refname> <refpurpose>Sets the default client character set</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>bool</type><methodname>mysqli_set_charset</methodname> <methodparam><type>mysqli</type><parameter>link</parameter></methodparam> <methodparam><type>string</type><parameter>charset</parameter></methodparam> </methodsynopsis> <para> The <function>mysqli_set_charset</function> function sets the default character set (specified by the <parameter>charset</parameter> parameter) to be used when sending data from and to the database server represented by the <parameter>link</parameter> parameter. </para> <note> <para> To use this function on a Windows platform you need MySQL client library version 4.1.11 or above (for MySQL 5.0 you need 5.0.6 or above) </para> </note> </refsect1> <refsect1> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <refsect1> &reftitle.seealso; <para> <function>mysqli_character_set_name</function>&listendand; <function>mysqli_real_escape_string</function>. </para> </refsect1> <refsect1> &reftitle.examples; <example> <title>Object oriented style</title> <programlisting role="php"> <![CDATA[ <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "test"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } /* change character set to utf8 */ if ($mysqli->set_charset("utf8")) { printf("Error loading character set utf8: %s\n", $mysql->error); } else { printf("Current character set: %s\n", $mysqli->character_set_name()); } $mysqli->close(); ?> ]]> </programlisting> </example> <example> <title>Procedural style</title> <programlisting role="php"> <![CDATA[ <?php $link = mysqli_connect('localhost', 'my_user', 'my_password', 'test'); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } /* change character set to utf8 */ if (mysqli_set_charset($link, "utf8")) { printf("Error loading character set utf8: %s\n", mysqli_error($link)); } else { printf("Current character set: %s\n", mysqli_character_set_name($link)); } mysqli_close($link); ?> ]]> </programlisting> </example> &example.outputs; <screen> <![CDATA[ Current character set: utf8 ]]> </screen> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->