1: 数据库的连接
<?php
$con = mysql_connect("localhost","root","123");
mysql_select_db("user",$con);
mysql_query(“ set names sjis “); //防止存取数据乱码设置编码格式
$sql = "select * from user where userId= ' ".$userId." ' ";
//在sql语句中插入变量 要用 ' ".$." ' 将变量包裹起来
$result = mysql_query($sql);
$rs = mysql_fetch_object($result);
if( $rs != null){
$pw = $rs->passWord; //通过结果集 $rs 获取其中passWord字段的值
}
while($row = mysql_fetch_object($result))
{
$row->id;
$row
}
$rs = mysql_fetch_array($result)是将结果放在一个数组中,取值应该是
$rs["id"];
?>
2: session 的设置与获取