1
<?php
//Template Name: download_form
get_header();
?>

<div id="primary" class="content-area">
    <main id="main" class="site-main">

    <form method="post">
        Full Name: <input type="TEXT" name="f_Name">
        <br><br>  
        Designation: <input type="TEXT" name="f_Desg">
        <br><br>
        Company Name: <input type="TEXT" name="f_Comp">
        <br><br>
        Address: <input type="TEXT" name="f_Addr">
        <br><br>

        <input type="SUBMIT" value="Submit" name="f_Submit">
    </form>

    <?php
        if(isset($_POST ['f_Submit']))
        {
            $name=$_POST ['f_Name'];

            $desg=$_POST['f_Desg'];
            $comp=$_POST['f_Comp'];
            $addr=$_POST['f_Addr'];

            global $wpdb;

            require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );

            $table_name = $wpdb->prefix. 'ppex_downloadform_data';

            $wpdb->show_errors();

            $wpdb->insert(

                        array(''.table_name.'',
                            'person'    =>  $name,
                            'position'  =>  $desg, 
                            'comoany'   =>  $company,
                            'Address'   =>  $addr),
                            array(
                                '%s',
                                '%s',
                                '%s',
                                '%s', 
                                )
                            );

            if ($wpdb->insert_id) {echo "Data inserted successfully";}
            else {echo "An error occurred while saving data";
            }
        }
    ?>  
    </main><!-- #main -->
</div><!-- #primary -->

List of Errors

Warning: strtolower() expects parameter 1 to be string, array given in C:\xampp\htdocs\brgsite\wp-includes\wp-db.php on line 2802

Warning: strtolower() expects parameter 1 to be string, array given in C:\xampp\htdocs\brgsite\wp-includes\wp-db.php on line 2699

Warning: explode() expects parameter 2 to be string, array given in C:\xampp\htdocs\brgsite\wp-includes\wp-db.php on line 2724

Warning: implode(): Invalid arguments passed in C:\xampp\htdocs\brgsite\wp-includes\wp-db.php on line 2725

WordPress database error: [Incorrect table name ''] SHOW FULL COLUMNS FROM `` An error occurred while saving data

1 Answer 1

1

You might want to use the variable $table_name instead of the text table_name :)

You can also remove '' and ., since adding an empty string at the beginning and the end is pointless :)

$wpdb->insert( array($table_name, ... ) );
Sign up to request clarification or add additional context in comments.

1 Comment

Also, appending an empty string either end of a variable seems like a pointless waste of time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.