我试图在MySQL表中设置权限,但我收到错误:
Warning: mysqli::query() expects parameter 1 to be string, object given in
/public/sites/staffpaneel.mc-wonderland.nl/index.php on line 656
Catchable fatal error: Object of class mysqli_result could not be converted
to string in /public/sites/staffpaneel.mc-wonderland.nl/index.php on line 679
有没有人为我解决这个问题,我已经尝试了很多东西,但没有任何效果
<?php
//Perms
$PermissiesUitlezen = mysqli_query($conn, "SELECT * FROM `RankPermissies` WHERE RankID ° '".$sqlDataIngelogd['RankID']."'");
$sqlDataPermissies = mysqli_fetch_assoc($PermissiesUitlezen);
if ($conn->query($PermissiesUitlezen) === TRUE) {
if ($sqlDataPermissies['AccountMakenMag'] == 1) {
AccountMakenMag();
}
if ($sqlDataPermissies['AccountsMag'] == 1) {
AccountsMag();
}
if ($sqlDataPermissies['MeldingMakenMag'] == 1) {
MeldingMakenMag();
}
if ($sqlDataPermissies['RankAanmakenMag'] == 1) {
RankAanmakenMag();
}
if ($sqlDataPermissies['RanksMag'] == 1) {
RanksMag();
}
if ($sqlDataPermissies['StoringMakenMag'] == 1) {
StoringMakenMag();
}
if ($sqlDataPermissies['StoringenMag'] == 1) {
StoringenMag();
}
} else {
echo "Fout: " . $PermissiesUitlezen . "<br>" . $conn->error;
}
?>
答案 0 :(得分:0)
可以从
更改您的查询吗?SELECT * FROM `RankPermissies` WHERE RankID ° '".$sqlDataIngelogd['RankID']."'
到
SELECT * FROM `RankPermissies` WHERE RankID = '".$sqlDataIngelogd['RankID']."'
然后检查。
答案 1 :(得分:0)
问题在于$PermissiesUitlezen
保留了mysqli_query()
来电的结果,而在if
中您将其用作另一个mysqli_query()
来电的参数。这没有任何意义。
实际上,如果您在php.net上阅读mysqli_query()上的手册,您就会知道如何正确检查错误:
if ($PermissiesUitlezen = mysqli_query($conn, "SELECT * FROM `RankPermissies` WHERE RankID = '".$sqlDataIngelogd['RankID']."'")) {
$sqlDataPermissies = mysqli_fetch_assoc($PermissiesUitlezen);
...
请注意,我还更正了sql语句(将°
替换为=
。但请注意,如果在sql查询中有参数,则应使用预准备语句。