wordpress.org – Fatal error: Uncaught Error: trim(): Argument #1 ($string) at \wp-includes\class-wp-query.php

I am using a form to submit table insert values ​​using <input name=[]> as $_POST on a PHP page. This is a template page in wordpress and i am getting an error.

Template Name: table page
global $wpdb;
$names= $wpdb-> get_results('select stdName FROM wp_nis_student');
<form action="" method="post" >
                <th>Student Name</th>

            <?php foreach($names as $name ){?>
                  <td><input type="text" name="name[]" value="<?php echo $name->stdName;>"/</td>
                  <td><input type="text" name="Engmark[]"/></td>
                  <td><input type="text" name="Mathmark[]"/></td>
                <?php }?>
    <button  type="submit" name="submit" value="Submit">Submit</button>
    if(isset($_POST['name'])&& isset($_POST['Engmark']) && isset($_POST['Mathmark'])){
         echo "Names: <br/>";
            foreach ( $_POST["name"] as $name ) 
              echo $name . "<br/>";
            echo "<br/><br/>" .
                 "English : <br/>";
            foreach ( $_POST["Engmark"] as $eng ) 
              echo $eng . "<br/>";

              echo "<br/><br/>" .
                 "Maths: <br/>";
            foreach ( $_POST["Mathmark"] as $mat ) 
              echo $mat . "<br/>";
     else echo "Error: no data";

and i am getting this error because am calling issuer($_POST[‘submit’],

Fatal error: Uncaught Error: trim(): Argument #1 ($string) must be of type string, given in array ..\wp-includes\class-wp-query.php on line 811

Then class-wp-query.php. A change was made to line 811 in $qv[‘name’] = trim($qv[‘name’] , $qv. for[‘name’] = trim($qv[‘name[], it worked fine but i started getting warnings on the website

Warning: Undefined array key "name[]" in ..\wp-includes\class-wp-query.php on line 811

how can i solve it?

Leave a Comment