function.mysql-connect.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 305 行 · 第 1/2 页
HTML
305 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Open a connection to a MySQL Server</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mysql-close.html">mysql_close</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mysql-create-db.html">mysql_create_db</a></div> <div class="up"><a href="ref.mysql.html">MySQL Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.mysql-connect" class="refentry"> <div class="refnamediv"> <h1 class="refname">mysql_connect</h1> <p class="verinfo">(PHP 4, PHP 5, PECL mysql:1.0)</p><p class="refpurpose"><span class="refname">mysql_connect</span> — <span class="dc-title">Open a connection to a MySQL Server</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><b><b>mysql_connect</b></b></span> ([ <span class="methodparam"><span class="type">string</span> <tt class="parameter">$server</tt></span> [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$username</tt></span> [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$password</tt></span> [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$new_link</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$client_flags</tt></span> ]]]]] )</div> <p class="para rdfs-comment"> Opens or reuses a connection to a MySQL server. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">server</tt></i></span> <dd> <p class="para"> The MySQL server. It can also include a port number. e.g. "hostname:port" or a path to a local socket e.g. ":/path/to/socket" for the localhost. </p> <p class="para"> If the PHP directive <a href="mysql.configuration.html#ini.mysql.default-host" class="link"> mysql.default_host</a> is undefined (default), then the default value is 'localhost:3306'. In <a href="ini.core.html#ini.sql.safe-mode" class="link">SQL safe mode</a>, this parameter is ignored and value 'localhost:3306' is always used. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">username</tt></i></span> <dd> <p class="para"> The username. Default value is defined by <a href="mysql.configuration.html#ini.mysql.default-user" class="link">mysql.default_user</a>. In <a href="ini.core.html#ini.sql.safe-mode" class="link">SQL safe mode</a>, this parameter is ignored and the name of the user that owns the server process is used. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">password</tt></i></span> <dd> <p class="para"> The password. Default value is defined by <a href="mysql.configuration.html#ini.mysql.default-password" class="link">mysql.default_password</a>. In <a href="ini.core.html#ini.sql.safe-mode" class="link">SQL safe mode</a>, this parameter is ignored and empty password is used. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">new_link</tt></i></span> <dd> <p class="para"> If a second call is made to <b>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. The <i><tt class="parameter">new_link</tt></i> parameter modifies this behavior and makes <b>mysql_connect()</b> always open a new link, even if <b>mysql_connect()</b> was called before with the same parameters. In <a href="ini.core.html#ini.sql.safe-mode" class="link">SQL safe mode</a>, this parameter is ignored. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">client_flags</tt></i></span> <dd> <p class="para"> The <i><tt class="parameter">client_flags</tt></i> parameter can be a combination of the following constants: 128 (enable <i>LOAD DATA LOCAL</i> handling), <b><tt>MYSQL_CLIENT_SSL</tt></b>, <b><tt>MYSQL_CLIENT_COMPRESS</tt></b>, <b><tt>MYSQL_CLIENT_IGNORE_SPACE</tt></b> or <b><tt>MYSQL_CLIENT_INTERACTIVE</tt></b>. Read the section about <a href="mysql.constants.html" class="xref">Predefined Constants</a> for further information. In <a href="ini.core.html#ini.sql.safe-mode" class="link">SQL safe mode</a>, this parameter is ignored. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a MySQL link identifier on success, or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 changelog">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?