I have this code in one file called: "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');
}
}
And here is the code for "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>
I expect to see whatever is fetched from my sql statement(edit-post.php) to be displayed in view_edit-post.php.. However, I'm getting these errors:
Undefined property: stdClass::$title
Undefined property: stdClass::$announcement
What could I've done wrong?
PS: I'm trying to figure this out for the past 2 days, tried everything,still without luck.