// If logged in, access mysql
$con = mysqli_connect(DB_HOST, DB_USER, DB_PASS) or die(mysqli_error);
$user = mysqli_fetch_assoc(mysqli_query($con, "SELECT * FROM users WHERE username='" . $_SESSION['username'] . "'"));
echo '<ul>';
我的表名为users
,我的用户名列为username
图片HERE
答案 0 :(得分:0)
查询不正确删除会话中的两个点 像这样查询
xor eax,eax
答案 1 :(得分:0)
首先,您不要定义DB_NAME(数据库名称)
$con = mysqli_connect(DB_HOST, DB_USER, DB_PASS,DB_NAME) or die(mysqli_error);
$userName = $_SESSION['username'];
$stmt = mysqli_query($con,"SELECT * FROM users WHERE username ='$userName' ");
while( $user = mysqli_fetch_assoc($stmt) ){
// if correct will pass to here
}
如果错误仍然存在 从数据库中获取任何名称并使用参数
进行切换