php无法重数据库内读出用户信息来 求解
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>个人中心</title>
</head>
<body>
<?php
session_start();
if(!isset($_SESSION['UID'])){
header("Location:login.html");
exit();
}
include('conn.php');
$userid = $_SESSION['UID'];
$username = $_SESSION['username'];
$user_query = mysql_query("select * from zhuce where Uid=$userid limit 1");
$row = mysql_fetch_row($user_query);
echo '用户信息:<br/>';
echo '用户ID:',$userid,'<br/>';
echo '用户名:',$username,'<br/>';
echo '邮箱:',$row['Mail'],'<br/>';
echo '出生日期: ',$row['Birthday'],'<br/>';
echo '固定电话: ',$row['Phone'],'<br/>';
echo '手机: ',$row['Mobile_telephone'],'<br/>';
echo '注册日期: ',$row['Date'],'<br/>';
echo '<a href="login.php?action=logout">注销</a> 登录<br/>';
?>
</body>
</html>
------解决方案--------------------$row = mysql_fetch_row($user_query);
得到的是下标数组
你用关联数组的方式如$row['Mail'],自然就得不到数据了
需要这样 $row[0]、$row[1] ....
这样
$row = mysql_fetch_assoc($user_query);
才可以
$row['Mail']、$row['Phone'] ....