Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > ebb1914cf182a88528b4547490db1dd8 > files > 1144

kdewebdev-quanta-doc-3.5.9-2mdv2008.1.x86_64.rpm

<HTML
><HEAD
><TITLE
>mysql_connect</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="manual.html"><LINK
REL="UP"
TITLE="MySQL functions"
HREF="ref.mysql.html"><LINK
REL="PREVIOUS"
TITLE="mysql_close"
HREF="function.mysql-close.html"><LINK
REL="NEXT"
TITLE="mysql_create_db"
HREF="function.mysql-create-db.html"></HEAD
><BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.mysql-close.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.mysql-create-db.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.mysql-connect"
>mysql_connect</A
></H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN18476"
></A
>mysql_connect -- Open a connection to a MySQL Server</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN18479"
></A
><H2
>Description</H2
><DIV
CLASS="funcsynopsis"
><P
></P
><CODE
CLASS="FUNCDEF"
>int mysql_connect</CODE
>(string 
      
       [<SPAN
CLASS="optional"
>hostname
	[<SPAN
CLASS="optional"
>:port</SPAN
>]
	[<SPAN
CLASS="optional"
>:/path/to/socket</SPAN
>]
       </SPAN
>]
      
     , string 
      
       [<SPAN
CLASS="optional"
>username</SPAN
>]
      
     , string 
      
       [<SPAN
CLASS="optional"
>password</SPAN
>]
      
     );<P
></P
></DIV
><P
> 
     Returns: A positive MySQL link identifier on success, or an error
     message on failure.
    </P
><P
> 
     <B
CLASS="function"
>mysql_connect()</B
> establishes a connection to a
     MySQL server.  All of the arguments are optional, and if they're
     missing, defaults are assumed ('localhost', user name of the user
     that owns the server process, empty password).
    </P
><P
>&#13;     The hostname string can also include a port
     number. eg. "hostname:port" or a path to a socket
     eg. ":/path/to/socket" for the localhost.
     <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
       Support for ":port" was added in PHP 3.0B4.
      </P
><P
>&#13;       Support for the ":/path/to/socket" was added in
       PHP 3.0.10.
      </P
><P
>&#13;      You can suppress the error message on failure by prepending '@'
      to the function name.
      </P
></BLOCKQUOTE
></DIV
>
    </P
><P
>&#13;     In case a second call is made to
     <B
CLASS="function"
>mysql_connect()</B
> with the same arguments, no
     new link will be established, but instead, the link identifier of
     the already opened link will be returned.
    </P
><P
>&#13;     The link to the server will be closed as soon as the execution of
     the script ends, unless it's closed earlier by explicitly calling
     <A
HREF="function.mysql-close.html"
><B
CLASS="function"
>mysql_close()</B
></A
>.
    </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><P
><B
>Example 1. MySQL connect example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>  1&nbsp;
  2&nbsp;&#60;?php
  3&nbsp;    $link = mysql_connect ("kraemer", "marliesle", "secret") {
  4&nbsp;        or die ("Could not connect");
  5&nbsp;    } 
  6&nbsp;    print ("Connected successfully");
  7&nbsp;    mysql_close ($link);
  8&nbsp;?&#62;
  9&nbsp;     </PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
> See also
     <A
HREF="function.mysql-pconnect.html"
><B
CLASS="function"
>mysql_pconnect()</B
></A
>, and
     <A
HREF="function.mysql-close.html"
><B
CLASS="function"
>mysql_close()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.mysql-close.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="manual.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.mysql-create-db.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>mysql_close</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.mysql.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>mysql_create_db</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>