I am getting a warning message while trying to update values in textfield but the values are getting updated in database. here is my code,

                            $id = $_GET['id'];
                            $action = $_GET['action'];

                            $page_name  = mysql_real_escape_string($_POST['page_name']);
                            $page_content = mysql_real_escape_string($_POST['page_content']);

                            if (isset($action) && $action=='edit')
                                $sql = "SELECT * FROM posts WHERE post_id=".$id;
                                $result = mysqli_query($con, $sql);

                            if (isset($_POST['submit'])) {
                                $sql = "UPDATE posts SET post_name = '".$page_name."', post_content = '".$page_content."' WHERE post_id=".$id;
                                $result = mysqli_query($con, $sql);

                            if (mysqli_num_rows($result) > 0) {
                                while($row = mysqli_fetch_assoc($result)) {
                        ?> <form action="edit-page.php?id=<?php echo $id; ?>" method="POST"> <legend>Edit page</legend> <input type="text" name="page_name" placeholder="page name" class="page-name-field" value="<?php if(isset($row["post_name"])) echo $row["post_name"]; ?>" required/> <textarea name="page_content" placeholder="place content here" class="page-content-field"><?php if(isset($row["post_content"])) echo $row["post_content"]; ?>
11 Months
Discussion Span
Last Post by jkon

For first:

  $id = $_GET['id'];
  $action = $_GET['action'];

is not good practice! It raise PHP error if not set. All request variables initialize like this:

$id = ( isset($_GET['id']) ? $_GET['id'] : '' );

"isset($action)" in to the line 9 is senseless, check it while initialize

$action = ( isset($_GET['action']) ? $_GET['action'] : 'edit' );

Edited by AndrisP

Votes + Comments
Hi, why not `filter_input()` then? https://php.net/filter-input

Of course , other two (three counting comments) great programmers have spend their time to help others and responded . The creator of the message didn't spend even a minute to respond. The message is crystal clear “mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given” what else can be said? In line 22 of the code there is a mysqli_num_rows($result) statement , that means that the parameter 1 ($result) isn't mysqli_result but boolean. What else could that mean ?

SubratPHP you had the time to upload a photo but not to respond to the people that dealt with your request for help. That is a very bad beginning not only in programming but in any work or community participation.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.