douwei1408 2014-05-07 20:21
浏览 104
已采纳

应该将内容打印到我的数据库中的模板的PHP代码

So I have made a template for the layout of my website that I use for every page and I want to get the content from my database. The content in my database is all just text and the html code is in my template.

All content is stored in the database named tblPages that contains pagesID (used to select the right row),inhoud (dutch for content, which is the main content on my page) and bubble (which is a little speech box).

Now the ID should be send in the link that is found in the navingation of the page, this I do with this line of code:

<php echo '<li><a href="index.php?id=3"><img src="../images/icons/home.png" alt="home">  </a> ?>

In this case it should give the content that is on row 3.

Now the error that I'm getting follows:

Warning: mysqli_stmt_bind_param() [function.mysqli-stmt-bind-param]: Number of variables doesn't match number of parameters in prepared statement in /Users/Caitlin/Pictures/School 2013-2014/GIP/Internet technieken/Caitlin_ArtMeetsArt/php/index.php on line 13

<php
require_once("../includes/dbconn.inc.php");
$inhoud = "";
$bubble = "";

if (!empty($_GET['id'])){
$id = $_GET['id'];
$qrySelectPage = "SELECT pagesID, inhoud, bubble
FROM tblPages";
if ($stmt = mysqli_prepare($dbconn, $qrySelectPage)) {
mysqli_stmt_bind_param($stmt, "s", $id); //LINE 13
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $pagesID, $inhoud, $bubble);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
}
}
$content = "";
$paginatitel = "Home";
$content .= '<p class="content1">' . $inhoud . '</p>';
$bubble .= '<p class="bubble">' . $bubble . '</p>';
require_once("../includes/ama_template.inc.php");
?>

And in my template is the following code

<html>
<body>
<?php echo $content; ?>
<?php echo $bubble; ?>
</body>
</html>

I left out most of my html code since it's probably not relevant. Since this is the only part that comes from my database.

  • 写回答

2条回答 默认 最新

  • doutang0335 2014-05-07 20:27
    关注

    Here's your query:

    $qrySelectPage = "SELECT pagesID, inhoud, bubble FROM tblPages";
    

    There are no parameters in that query. You need to add something like WHERE id=? and then bind a value to that parameter (the ?).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条