我是PHP的初学者,并试图学习它。我的布尔值返回false,我找不到如何解决这个问题的答案。谢谢!
$leden_id = $_POST["leden_id"];
$connect = mysqli_connect("localhost", "root", "root", "bibliotheek");
$ophalen = "SELECT naam FROM leden WHERE leden = " . $leden_id . ";";
$r = mysqli_query($connect, $ophalen);
var_dump($r);
答案 0 :(得分:0)
检查这个并且未经过测试 变化
$ophalen = "SELECT naam FROM leden WHERE leden = " . $leden_id . ";";
到
$ophalen = "SELECT naam FROM leden WHERE leden = '" . $leden_id . "'";
如果您的帖子值很好,请检查此
$leden_id = $_POST["leden_id"];
$connect = mysqli_connect("localhost", "root", "root", "bibliotheek");
$ophalen = "SELECT naam FROM leden WHERE leden = '" . $leden_id . "'";
$r = mysqli_query($connect, $ophalen);
var_dump($r);
答案 1 :(得分:0)
您的$ophalen
值出错,您的代码未使用单引号和双引号正确关闭查询。另外,请记住检查SQL注入。
将您的代码替换为:
$leden_id = $_POST["leden_id"];
$connect = mysqli_connect("localhost", "root", "root", "bibliotheek");
$ophalen = "SELECT naam FROM leden WHERE leden = '" . $leden_id . "'";
$r = mysqli_query($connect, $ophalen);
var_dump($r);
答案 2 :(得分:0)
除了常见的SQL注入问题之外,让我给你一些关于调试的指示:
$ophalen = "SELECT naam FROM leden WHERE leden = '" . $leden_id . "'"; // Change this line
$r = mysqli_query($connect, $ophalen) or die (mysqli_error($connect)); // Check for errors
答案 3 :(得分:0)
谢谢大家的帮助! 我会阻止SQL注入,它不会用于实际的网站,这是我用来练习的任务。
我用过
or die (mysqli_error($connect));
并发现此错误在“where子句”中弹出“未知列'leden'” 所以我必须再次查看我的数据库。
谢谢!