无法从MySQL-PHP获取数据

无法从MySQL-PHP获取数据,php,mysql,variables,Php,Mysql,Variables,我将从代码开始: $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_co

我将从代码开始:

$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代码输入也会得到正确的响应。我不太确定这里出了什么问题。有人知道吗?

你需要知道,而不是

因此,改变:

$stmt->store_result();
致:


我认为你应该发布你正在使用的DB类。我只能猜测你的方法背后有什么。如果SQL查询工作正常,则类中应该有任何错误。将
bind_-param(“s”,$permission)
更改为
bind_-param(1,$permission)
$stmt->fetch();