I am currently working on a small task that store a plugin information into database, but I have problem regarding to include the file that has the functions to run the query.

Here is the line that includes the file:

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

but I got the following when I run the code:

Warning: require_once(ABSPATHwp-admin/includes/upgrade.php): failed to open stream: No such file or directory in /home/najam/dev/project1/wordpress/wp-admin/admin-insert.php on line 18

I searched a lot but can't find anything useful or helpful.


Here is my code:

global $wpdb;

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

$sql = "CREATE TABLE $table_name (
  rows int(11) DEFAULT NULL,
  cols int(11) DEFAULT NULL,
  UNIQUE KEY id (id)

require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta( $sql );`
  • 4
    Where is this code?
    – s_ha_dum
    Commented Feb 14, 2014 at 5:32
  • 2
    ABSPATH does not appeared to be defined. Where are you using it? Commented Feb 14, 2014 at 5:34
  • You probably missed a trailing slash after the ABSPATH and before wp-admin/. Try this: ABSPATH . '/wp-admin/. And consider this StackOverflow WP Question also. Commented Feb 14, 2014 at 5:36
  • 2
    What is the file /wp-admin/admin-insert.php? This is not in the core. Are modifying the WordPress core? Commented Feb 14, 2014 at 6:07
  • 1
    @Mayeenul Islam no, no trailing slash required after ABSPATH. ABSPATH variable already contains trailing slash...
    – Shail
    Commented Jun 14, 2014 at 11:10

5 Answers 5


insert.php file that I made myself, actually I am new to wordpress, I want to that is there any mistake that i am making? Actually I want to store a plugin form information in the database.

Your question is very light on detail but I suspect that the mistake you are making is loading a file in such a way as it loads outside the context of WordPress, or in such a way that only parts of WordPress get loaded.

The lack of detail in your question-- the near complete lack of context for the code-- makes it impossible to provide a solid answer but I am leaning toward suggesting that you need to run your code via the AJAX API (even if not strictly AJAX). Something like this: https://wordpress.stackexchange.com/a/108145/21376

If you want a better answer, you must write a better question. Please click the "edit" button under your question and add as much detail as you can, but keep it organized.

  • I'd be quite worried that a database table is being created inside an AJAX call fullstop
    – Tom J Nowell
    Commented Aug 15, 2014 at 1:04

there is a nice WordPress function that helps you anytime you don't want to check for missing "/" on your path.


your example should be the recommended way written:

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

using this function, you never have to put "/" in front of your "relative" path, as this function makes sure that "/" will be in case is missing.

this is why we have created that function in WordPress.


ABSPATH will work you need to include wp-load file. include '../../../wp-load.php';


You should not need the / but try a slash at the start of the /wp-admin

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

But did you check if /wp-admin/admin-insert.php file exists?

Is the ABSPATH defined? Add the following to check:

// Is ABSPATH defined?
if ( !defined('ABSPATH') )

Also, are you trying to run this without loading WP? Plus, you could try site_url() and work with it.


ABSPATH should contain a trailing slash already. You need to include your upgrade file from the main plugin's file. Maybe you need to hook into 'plugins_loaded' action or 'init' and then call the upgrade method.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.