以下的文章主要介绍的是php连接MySQL数据库的实际操作流程,以及对其实际操作中需要用到的代码的描述,以下的文章就是对php连接MySQL数据库的实际操作流程以及其实际应用代码的描述。
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- 1.
PHP操作MySQL
extension=php_MySQL.dll打开
<?php
$servername = "127.0.0.1";
$username = "root";
$password = "123456";
$conn = MySQL_connect($servername, $username, $password);
- 1.
- 2.
- 3.
- 4.
- 5.
建立MySQL连接
if($conn) {
echo "连接成功";
}
//MySQL_select_db("easytoo");
- 1.
- 2.
- 3.
- 4.
选择要连接MySQL数据库
或者
MySQL_query("use easytoo",$conn);
- 1.
选择要连接MySQL数据库
MySQL_query("SET NAMES utf8");
$rs = MySQL_query("select id from et_category");
- 1.
- 2.
查询获取一个数据集
MySQL_num_rows($rs);
- 1.
得到记录集总数
while($row=mysql _fetch_array($rs))
- 1.
循环数据集
{
echo "$row[0]<br>";
}
mysql_free_result($rs);
- 1.
- 2.
- 3.
- 4.
释放rs
mysql_close($conn);
- 1.
关闭连接
?>
- 1.
以上的相关内容就是对php连接MySQL数据库的介绍,望你能有所收获。
【编辑推荐】