[转帖]php mysql_connect() 函数使用方法详解_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 1863 | 回复: 0   主题: [转帖]php mysql_connect() 函数使用方法详解        下一篇 
justfriend
注册用户
等级:新兵
经验:61
发帖:62
精华:0
注册:2011-11-21
状态:离线
发送短消息息给justfriend 加好友    发送短消息息给justfriend 发消息
发表于: IP:您无权察看 2014-11-6 9:50:25 | [全部帖] [楼主帖] 楼主

Definition and Usage

定义和用法

 The mysql_connect() function opens a non-persistent MySQL connection.

mysql_connect()函数的作用是:打开一个到 MySQL 服务器的连接。

This function returns the connection on success, or FALSE and an error on failure. You can hide the error output by adding an '@' in front of the function name.

该函数如果成功执行,将返回这个连接,如果失败,将返回False。当然你也可以在函数名称前面添加一个“@”来隐藏产生的错误。

Syntax

语法

 server

Optional. Specifies the server to connect to (can also include a port number. e.g. "hostname:port" or a path to a local socket for the localhost). Default value is "localhost:3306"

可选参数。指定需要连接的服务器(他可以包含一个端口号。案例:“hostname:port”,或者一个连接到本地服务器的路径)。默认值为:“localhost:3306”

 user

Optional. Specifies the username to log in with. Default value is the name of the user that owns the server process

可选参数。指定登陆的用户名。默认的用户名是该服务器拥有者的名字

 pwd

Optional. Specifies the password to log in with. Default is ""

可选参数。指定登陆的密码。默认值为""

 newlink

Optional. If a second call is made to mysql_connect() with the same arguments, no new connection will be established; instead, the identifier of the already opened connection will be returned

可选参数。如果你使用相同的自变量对mysql_connect()函数发出第二次请求,那么,它将建立一个新的连接;同样,它将返回已经打开的连接

 clientflag

Optional. Can be a combination of the following constants:

 可选参数。可以使用的值如下:

MYSQL_CLIENT_SSL - Use SSL encryption

MYSQL_CLIENT_SSL – 使用SSL技术加密

 MYSQL_CLIENT_COMPRESS - Use compression protocol

MYSQL_CLIENT_COMPRESS – 使用压缩[compression]协议

 MYSQL_CLIENT_IGNORE_SPACE - Allow space after function names

MYSQL_CLIENT_IGNORE_SPACE – 允许在函数名称后面出现空格

 MYSQL_CLIENT_INTERACTIVE - Allow interactive timeout seconds of inactivity before closing the connection

MYSQL_CLIENT_INTERACTIVE – 在关闭连接之前,允许对休止状态下的函数设置激活时间

 Tips and Notes

提示

 Tip: The connection will be closed as soon as the script ends. To close the connection before, use mysql_close().

提示:但脚本程序结束运行后,连接将被关闭;你可以使用mysql_close()函数关闭这个连接。

Tip: To establish a persistent MySQL connection, use mysql_pconnect() instead.

提示:你可以使用mysql_pconnect()函数建立一个持久的MySQL连接。

Example

案例

<?php

$con = mysql_connect("localhost","mysql_user","

mysql_pwd");

if (!$con) { die('Could not connect: ' . mysql_error()); }

// some code

mysql_close($con);?>

--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论