Title: Insert Query not working
Last modified: August 19, 2016

---

# Insert Query not working

 *  [mufaddal](https://wordpress.org/support/users/mufaddal/)
 * (@mufaddal)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/insert-query-not-working/)
 * 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!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/insert-query-not-working/#post-1018212)
 * 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.
 *  Thread Starter [mufaddal](https://wordpress.org/support/users/mufaddal/)
 * (@mufaddal)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/insert-query-not-working/#post-1018333)
 * 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.
 *  [yakuphan](https://wordpress.org/support/users/yakuphan/)
 * (@yakuphan)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/insert-query-not-working/#post-1018334)
 * Use the following codes
    $table_name = $wpdb->prefix . “ticket”; $wpdb->query(“
   INSERT INTO $table_name (CompanyName, CustomerName) VALUES(‘test1′,’test 2’)”);
 *  Thread Starter [mufaddal](https://wordpress.org/support/users/mufaddal/)
 * (@mufaddal)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/insert-query-not-working/#post-1018341)
 * still facing the same problem.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/insert-query-not-working/#post-1018344)
 * This may help: [Creating_Tables_with_Plugins](http://codex.wordpress.org/Creating_Tables_with_Plugins)

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Insert Query not working’ is closed to new replies.

## Tags

 * [query](https://wordpress.org/support/topic-tag/query/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [17 years, 3 months ago](https://wordpress.org/support/topic/insert-query-not-working/#post-1018344)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
