好的,所以我现在已经在这几个小时了,不管我做什么,它都行不通。我已经阅读了文档页面,甚至通过示例逐字尝试,但仍然不起作用:
$db = mysqli_connect($db_server, $db_user, $db_passwd, $db_name);
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$db_query = "SELECT ca.id_article, ca.title, ca.body, ca.id_tag, ca.visible, ct.title AS tag_title
FROM cdfi_articles AS ca
INNER JOIN cdfi_tags AS ct ON(ct.id_tag = ca.id_tag)
WHERE ca.id_article = ?
LIMIT 1";
;
if ($stmt = mysqli_prepare($db, $db_query)) {
mysqli_stmt_bind_param($stmt, "i", $_REQUEST['article']);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $return);
mysqli_stmt_fetch($stmt);
var_dump($return);
}
mysqli_close($db);
发生以下错误,我根本不知道如何修复它:
Warning: mysqli_stmt_bind_result() [function.mysqli-stmt-bind-result]: Number of bind variables doesn't match number of fields in prepared statement in ... filepath on line {line number}
bind variables
不匹配?我只使用1个变量,查询中只有1个问号,给出了什么?
var_dump($return)
返回NULL
值
我该如何解决这个问题?我只想在$return
变量中返回1行,以便我可以用它做一些事,arggg!
答案 0 :(得分:3)
您正在选择6列但您只在$return
mysqli_stmt_bind_result($stmt, $return);
尝试
mysqli_stmt_bind_result($stmt, $artid, $title, $body, $tagid, $vis, $tagtitle );