WordPress.org

Ready to get started?Download WordPress

Forums

Insert Query not working (6 posts)

  1. mufaddal
    Member
    Posted 5 years ago #

    I am using Jquery Ajax Submit i have a action.php where all my code resides now the Jquery Posts the data but its not inserting it and either its giving an error, this is how the page looks..

    require_once('/wp-load.php');
    require_once('/wp-config.php');

    global $wpdb;
    $wpdb->query("INSERT INTO $wpdb->ticket (CompanyName, CustomerName) VALUES('test1','test 2')");

    I am new to wordpress, please can anyone help!

  2. MichaelH
    Member
    Posted 5 years ago #

    If you are getting an error, you might list that error so someone might be able to help you.

    Also assuming that you have the 'xxx_ticket' table in your WordPress database. The 'xxx_' would be the $table_prefix in your wp-config.php file.

    If you are using a plugin, please report a link to that plugin as well.

  3. mufaddal
    Member
    Posted 5 years ago #

    No there is no error displayed, on Database table name is wp_table and prefix on wp-config.php is "wp_"
    I am creating a new plugin so stuk on inserting records can you please tell me what all is needed for simple insert.

  4. yakuphan
    Member
    Posted 5 years ago #

    Use the following codes
    $table_name = $wpdb->prefix . "ticket";
    $wpdb->query("INSERT INTO $table_name (CompanyName, CustomerName) VALUES('test1','test 2')");

  5. mufaddal
    Member
    Posted 5 years ago #

    still facing the same problem.

  6. MichaelH
    Member
    Posted 5 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic