set home page
Added to the favorites
All articles(网络文学目录)
All Pictures(图片目录)
All Softwares(软件目录)
如何在十天学内会php之第四天_php资料_编程技术
Writer:
aaa
Article type:
Programming skills(编程技巧)
Time:
2013/12/21 22:37:24
Browse times:
285
Comment times:
0
如何在十天学内会php之第四天_php资料_编程技术
Head photo
Go homepage
Upload pictures
Write articles
如何在十天学内会php之第四天_php资料_编程技术-你的首页-uuhomepage.com
学习目的:学会连接数据库
我这里就简单说一下连接MYSQL数据库。
1、mysql_connect
打开 MySQL 服务器连接。
语法: int mysql_connect(string [hostname] [:port], string [username], string [password]); 返回值: 整数
本函数建立与 MySQL 服务器的连接。其中所有的参数都可省略。当使用本函数却不加任何参数时,参数 hostname 的默认值为 localhost、参数 username 的默认值为 PHP 执行行程的拥有者、参数 password 则为空字符串 (即没有密码)。而参数 hostname 后面可以加冒号与端口号,代表使用哪个端口与 MySQL 连接。当然在使用数据库时,早点使用 mysql_close() 将连接关掉可以节省资源。
2、 mysql_select_db
选择一个数据库。
语法: int mysql_select_db(string database_name, int [link_identifier]); 返回值: 整数
本函数选择 MySQL 服务器中的数据库以供之后的资料查询作业 (query) 处理。成功返回 true,失败则返回 false。
最简单的例子就是:
$conn=mysql_connect ("127.0.0.1", "", "");
mysql_select_db("shop");
连接机MY SQL数据库,打开SHOP数据库。在实际应用中应当加强点错误判断。
今天就说到这里,明天再说一下数据库的读取。
There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)
Comments can't is empty(评论不能为空)
Disclaimer
Privacy Policy
About us
Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.