为什么INSERT在mysql表中的每个查询下面添加额外的空行?

My code:

    $conn = mysqli_connect($servername, $username, $password, $database);

    $n = mysqli_real_escape_string($conn, $_REQUEST['n']);
    $m = mysqli_real_escape_string($conn, $_REQUEST['m']);

    $sql = "INSERT INTO wishform (n,m) VALUES ('$n','$m');";

    if(mysqli_query($conn, $sql)) {
         echo "Your ID is created successfully!";
    } else {
         echo "Error!";
    }

    mysqli_close($conn);
    

In Table:

    308 Name1   Messege1
    309     
    310 Name2   Messege2
    311     
    312 Name3   Messege3
    313

I think the problem is, you are not checking whether the data is submitted or not. Say for example, you have written this code in your PHP file as it is, without checking whether the user has submitted any data and that $_REQUEST['n'] and $_REQUEST['m'] are not empty!

So if you are not checking whether the data is submitted or not, probably you are running that piece of code each time when the page is executed, and inserts empty data to the databse!

Here's a simple idea to get you started:

if ($_SERVER['REQUEST_METHOD'] === 'POST') {

    //-- get the data from $_POST array (since we are expecting the data submitted via POST method, otherwise use $_GET array)
    //-- we are trimming any extra spaces
    $n = trim( $_POST['n'] );
    $m = trim( $_POST['m'] );

    if( ! empty( $n ) AND ! empty( $m ) )
    {
        $conn = mysqli_connect($servername, $username, $password, $database);

        $n = mysqli_real_escape_string($conn, $n);
        $m = mysqli_real_escape_string($conn, $m);

        $sql = "INSERT INTO wishform (n,m) VALUES ('$n','$m');";

        if(mysqli_query($conn, $sql)) {
             echo "Your ID is created successfully!";
        } else {
             echo "Error!";
        }

        mysqli_close($conn);
    }
    else
        echo 'No data submitted!';

}

Hope it helps!