1

我将从代码开始:

$permission = $_SESSION['permission'];
// Connect to database
$con = new mysqli("localhost", "privateinfo", "privateinfo", "privateinfo");

// Check connection
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

// Prepare to select all liabilities
$stmt = $con->prepare("SELECT `Linking`, `Edit_Liab`, `Own_Stud`, `All_Stud`, `View_Report`, `Read_Write` FROM Permissions WHERE `ID`=?");
$stmt->bind_param("s", $permission);  // Bind variables to the result of the query
$stmt->execute(); // Execute the query
$stmt->bind_result($linking, $editliab, $ownstud, $allstud, $viewrep, $readwrite); // Bind variables to the result of the query
$stmt->store_result();
$stmt->close();

基本上,我的问题是 php 没有得到任何变量。进来的所有变量都应该是 1,但实际上它们都为零。连接很好,我尝试将 die 语句放在字面上的所有内容上以提出错误,但没有任何结果。进入的权限变量也设置正确。将其作为 SQL 代码直接放入也会产生正确的响应。我不太确定这里出了什么问题。有人知道吗?

4

1 回答 1

0

您需要获取一行而不是存储结果

所以改变:

$stmt->store_result();

至:

$stmt->fetch();
于 2013-05-16T17:52:24.167 回答