为什么没有显示提取的记录?

时间:2014-11-18 03:08:38

标签: php html forms mysqli

我将此代码放在一个名为“edit-post.php”

的文件中
if (isset($_GET['ide'])) {

        $id = $_GET['ide'];

        $sql = $mysqli->query("SELECT * FROM posts WHERE id = {$id}");
        $row = $sql->fetch_object();

        if ($sql) {
            include('view_edit-post.php');  
        } 
    }

以下是“view_edit-post.php”的代码

<div id="edit-post">
    <div id="header">
        <span class="title">Edit post</span>
    </div>
    <div class="content-wrapper">
        <form action="" method="post" enctype="multipart/form-data">
            <input type="text" name="title" value="<?php echo $row->title ?>"/><br/>
            <textarea name="announcement" ><?php echo $row->announcements ?></textarea><br/>
            <input type="file" name="file"/><br/>
            <input type="submit" name="update" value="Update"/>
        </form>
    </div>
</div>

我希望看到从我的sql语句(edit-post.php)获取的内容在view_edit-post.php中显示。但是,我收到了这些错误:

Undefined property: stdClass::$title
Undefined property: stdClass::$announcement

我做错了什么?

PS:我试图在过去的两天里弄清楚这一点,尝试了一切,仍然没有运气。

0 个答案:

没有答案