最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
连接到 MySQL 数据库
时间:2022-11-14 23:38:33 编辑:袖梨 来源:一聚教程网
连接到 MySQL 数据库
创建一个连接到MySQL数据库
在您可以存取数据库中的数据,您必须创建一个连接到数据库。
在PHP中,这一点与mysql_connect ( )函数。
语法
mysql_connect(servername,username,password);
Parameter | Description |
---|---|
servername | Optional. Specifies the server to connect to. Default value is "localhost:3306" |
username | Optional. Specifies the username to log in with. Default value is the name of the user that owns the server process |
password | Optional. Specifies the password to log in with. Default is "" |
注:有更多的可用参数,但上面列出的是最重要的。访问我们充分的PHP MySQL的参考更详细的信息。
例如
在下面的例子中,我们存储连接在一个变量( $控制)以供日后使用的脚本。该“死”的一部分将被处死,如果连接失败:// some code?>关闭连接
连接将自动关闭时,脚本的目的。要关闭连接之前,请使用mysql_close ( )函数:
// some codemysql_close($con); ?>
相关文章
- 无限暖暖神秘作者任务怎么做 神秘作者任务流程攻略 09-18
- 如鸢董奉怎么玩 董奉玩法攻略 09-18
- 嘟嘟脸恶作剧活泼队怎么搭配 活泼队搭配推荐 09-18
- 如鸢曹植值得抽吗 曹植抽取建议 09-18
- 如鸢主线9-13王允低练度怎么过 主线9-13王允低练度过关攻略 09-18
- 嘟嘟脸恶作剧薇尔薇特角色如何 09-18