试图使我的博客安全并学习准备好的语句。准备语句获取db中的所有结果,但不是我要求的
尽管我设置了变量,但我仍然从数据库中获取所有条目。 $ escapedGet在打印出来时是真正的变量。这显然是一个新秀错误,但我似乎找不到答案。
我需要获取数据,其中postlink是$ escapedGet不是所有的数据。
$escapedGet = mysql_real_escape_string($_GET['article']);
// Create statement object
$stmt = $con->stmt_init();
// Create a prepared statement
if($stmt->prepare("SELECT `title`, `description`, `keywords` FROM `post` WHERE `postlink` = ?")) {
// Bind your variable to replace the ?
$stmt->bind_param('i', $postlink);
// Set your variable
$postlink = $escapedGet;
// Execute query
$stmt->execute();
$stmt->bind_result($articleTitle, $articleDescription, $articleKeywords);
while($stmt->fetch()) {
echo $articleTitle, $articleDescription, $articleKeywords;
}
// Close statement object
$stmt->close();
}
只是tryed这一点:echo $escapedGet; echo $_Get['artcile']
,并得到 - some_other 那,我已经保存在数据库中postlink
试图善德postlink到ID,然后它的工作相同的条目。但为什么不与后链接选项卡?
CANU告诉我表和$ escapedGet价值 – PSR 2013-03-20 10:37:45
我试着使用$ _GET代替$ escapedGet [“文章”],同样的结果,然后我试着使用数据库的确切值,并且仍然得到所有结果。 – maarcs 2013-03-20 10:40:46
尝试将一个静态值代替$ escapedGet,然后我们可以找到问题在哪里它是 – PSR 2013-03-20 10:41:47