-3

所以我曾经通过以下方式获得当前用户的权限:

 $dbQuery_ar = "SELECT * "; 

$dbQuery_ar .= "FROM users WHERE gebruikersnaam = ('$_SESSION[gebruikersnaam]')"; 
$result_ar = mysql_query($dbQuery_ar) or die("Couldn't get file list");
while($row = mysql_fetch_array($result_ar))
{

 $rechten = "$row[rechten]";      // get access level
 $_SESSION["rechten"] = "$rechten";      // make session variables 

}

有人可以告诉我如何编写包括会话用户名的 pdo 查询吗?

4

1 回答 1

0

它实际上必须是什么

<?php
$stmt = $conn->prepare('SELECT rechten FROM users WHERE gebruikersnaam = ?');
$query->execute(array($_SESSION["gebruikersnaam"]));
$_SESSION["rechten"] = $query->fetchColumn();

另请参阅标签 wiki以获取正确的连接选项

于 2013-06-20T15:34:27.257 回答