php-doc-en/reference/mysqli/functions/mysqli-connect.xml

73 lines
3.4 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<refentry id="function.mysqli-connect">
<refnamediv>
<refname>mysqli_connect</refname>
<refpurpose>Open a new connection to the MySQL server</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>resource</type><methodname>mysqli_connect</methodname>
<methodparam choice='opt'><type>string</type><parameter>hostname</parameter></methodparam>
<methodparam choice='opt'><type>string</type><parameter>username</parameter></methodparam>
<methodparam choice='opt'><type>string</type><parameter>passwd</parameter></methodparam>
<methodparam choice='opt'><type>string</type><parameter>dbname</parameter></methodparam>
<methodparam choice='opt'><type>int</type><parameter>port</parameter></methodparam>
<methodparam choice='opt'><type>string</type><parameter>socket</parameter></methodparam>
</methodsynopsis>
<para>
The <function>mysqli_connect</function> attempts to open a connection to the MySQL Server running
on <parameter>host</parameter> which can be either a hostname or an IP address. Passing the NULL
value or the string "localhost" to this parameter, the local host is assumed. When possible, pipes
will be used instead of the TCP/IP protocol. If successful, the <function>mysqli_connect</function>
will return a resource representing the connection to the database, or FALSE on failure.
</para>
<para>
The <parameter>username</parameter> and <parameter>password</parameter> parameters specify the
username and password under which to connect to the MySQL server. If the password is not provided
(the NULL value is passed), the MySQL server will attempt to authenticate the user against those
user records which have no password only. This allows one username to be used with different
permissions (depending on if a password as provided or not).
</para>
<para>
The <parameter>dbname</parameter> parameter if provided will specify the default database to be
used when performing queries.
</para>
<para>
The <parameter>port</parameter> and <parameter>socket</parameter> parameters are used in
conjunction with the <parameter>hostname</parameter> parameter to further control how to connect
to the database server. The <parameter>port</parameter> parameter specifies the port number to
attempt to connect to the MySQL server on, while the <parameter>socket</parameter> parameter
specifies the socket or named pipe that should be used.
</para>
<note>
<para>
Specifying the <parameter>socket</parameter> parameter will not explicitly determine the type
of connection to be used when connecting to the MySQL server. How the connection is made to the
MySQL database is determined by the <parameter>host</parameter> parameter.
</para>
</note>
</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
-->