I want to make this form get the id from the url suppose : http://localhost/x/y/index.php?id=1 and update the data in the article table, however i am getting the error: Fatal error: Call to a member function query() on boolean in http://localhost/x/y/index.php in line 38 which is the line highlighted in the code with ** at start and end.
<?php
include('db/db.php');
$id = $_GET['id'];
$select_db = "SELECT * FROM article WHERE ID=$id";
$run_news = mysql_query($select_db);
while($row=mysql_fetch_array($run_news)){
$post_id = $row['ID'];
$post_title = $row['title'];
$post_date = $row ['date'];
$post_author = $row['author'];
$post_keywords = $row['keywords'];
$post_image= $row['image'];
$post_content = $row['content'];
}
?>
<form action="" method="post">
<div>
<p><strong>ID:</strong> <?php echo $id; ?> </p>
<strong>Title: *</strong> <input type="text" name="title" value="<?php echo $post_title; ?>"/><br/>
<strong>Author: *</strong> <input type="text" name="author" value="<?php echo $post_author; ?>"/><br/>
<strong>Keywords: *</strong> <input type="text" name="keywords" value="<?php echo $post_keywords; ?>"/><br/>
<strong>image: *</strong> <input type="text" name="image" value="<?php echo $post_image; ?>"/><br/>
<strong>content: *</strong> <input type="text" name="content" value="<?php echo $post_content; ?>"/><br/>
<input type="submit" name="update" value="Submit">
</div>
</form>
<?php
// Code for UPDATE button
if (isset($_POST['update'])) {
$id = $_GET['id'];
$post_title = $_POST['title'];
$post_author = $_POST['author'];
$post_keywords = $_POST['keywords'];
$post_image = $_POST['image'];
$post_content = $_POST['content'];
$sql = "UPDATE article SET title='$post_title',author='$post_author',keywords=$post_keywords,content='$post_content' WHERE ID='$id'";
**$newdb = $con->query($sql,TRUE);**
$q = $newdb->query("SELECT * FROM article");
}
?>