Title: Cannot retrieve user options from database (#2)
Last modified: August 30, 2016

---

# Cannot retrieve user options from database (#2)

 *  Resolved [Jochen Gererstorfer](https://wordpress.org/support/users/gmmedia/)
 * (@gmmedia)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/)
 * Hello,
    I can not get the NF plugin to work. I get the following error: `Cannot
   retrieve user options from database (#2).`
 * What does that mean?
 * ninjacheck.php output:
 *     ```
       HTTP server	:	Apache/2.2.22 (Debian)
       PHP version	:	5.4.41-0+deb7u1
       PHP SAPI	:	APACHE2HANDLER
   
       auto_prepend_file	:	/var/www/web0/html/wordpress/wp-content/plugins/ninjafirewall/lib/firewall.php
       NinjaFirewall detection	:	NinjaFirewall is loaded but returned error code #5
   
       Loaded INI file	:	/etc/php5/apache2/php.ini
       user_ini.filename	:	.user.ini
       user_ini.cache_ttl	:	300 seconds
       User PHP INI	:	none found
   
       DOCUMENT_ROOT	:	/var/www/web7/html/wordpress
       wp-config.php	:	found in /var/www/web0/html/wordpress/wp-config.php
       ABSPATH	:	/var/www/web0/html/wordpress/ (ABSPATH != DOCUMENT_ROOT)
       WordPress version	:	4.2.2
       WP_CONTENT_DIR	:	/var/www/web0/html/wordpress/wp-content
       Plugins directory	:	/var/www/web0/html/wordpress/wp-content/plugins
       ```
   
 * thank you
    Jochen
 * [https://wordpress.org/plugins/ninjafirewall/](https://wordpress.org/plugins/ninjafirewall/)

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

 *  Plugin Author [nintechnet](https://wordpress.org/support/users/nintechnet/)
 * (@nintechnet)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218020)
 * Hi,
 * That means that there is an error when it tries to read its configuration from
   the database.
 * You can try our test script: [http://nintechnet.com/ninjadb_php.txt](http://nintechnet.com/ninjadb_php.txt)
 * Rename it to ninjadb.php, upload it into your WordPress root folder (this is 
   the folder where your index.php and wp-config.php are located by default), then
   visit http:// yourblog/ninjadb.php with your browser.
    It will give more details
   about the DB connection.
 *  Thread Starter [Jochen Gererstorfer](https://wordpress.org/support/users/gmmedia/)
 * (@gmmedia)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218032)
 * Thank you.
 * Its a multisite setup. The script tires to select the wrong table.
 * The right table is usr_webx_2.wp_x2_options not usr_webx_2.wp_options.
 *     ```
       Found wp-config.php.
       Opening it for reading.
       Looking for DB_NAME, DB_USER, DB_PASSWORD, DB_HOST and $table_prefix:
       DB_NAME: found
       DB_USER: found
       DB_PASSWORD: found
       DB_HOST: found
       table_prefix: found
       Attempting to connect to the DB: OK
       Attempting to read NinjaFirewall's options (nfw_options) from the DB: Error: Table 'usr_webx_2.wp_options' doesn't exist
       Exiting.
       ```
   
 *  Plugin Author [nintechnet](https://wordpress.org/support/users/nintechnet/)
 * (@nintechnet)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218085)
 * Is “wp_x2_” the table prefix in your wp-config.php file ?
 *  Thread Starter [Jochen Gererstorfer](https://wordpress.org/support/users/gmmedia/)
 * (@gmmedia)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218087)
 * No, the prefix in the wp-config.php is “wp_”
 * Its a multisite installation, so x2 is the ID of that multisite blog. Its called
   blog_id.
 * Here you can read about the multisite specific tables: [https://codex.wordpress.org/Database_Description#Site_Specific_Tables](https://codex.wordpress.org/Database_Description#Site_Specific_Tables)
 *  Plugin Author [nintechnet](https://wordpress.org/support/users/nintechnet/)
 * (@nintechnet)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218115)
 * Normally, the main site tables should be named “prefix” + “table” (e.g., wp_options)
   as usual and, of course, all other sites should have the blog_id inserted as 
   you mentioned it.
 * Why does your main site has the blog_id #2 ? Did you delete the original or did
   you perform a specific installation?
 *  Thread Starter [Jochen Gererstorfer](https://wordpress.org/support/users/gmmedia/)
 * (@gmmedia)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218127)
 * Oh I understand.
    My installation is very old (since WPMU), so I dont remember
   what exactly happened in the past. The config table of my main site is wp_1_config.
   There is no wp_config table.
 * But I found the NinjaFirewall settings (nfw_options and nfw_rules) in the wp_config
   table of the blog, where I have installed the NF. Thats the table wp_62_options.
 *  Plugin Author [nintechnet](https://wordpress.org/support/users/nintechnet/)
 * (@nintechnet)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218165)
 * I am afraid you will not be able to run NinjaFirewall if your main blog has a
   blog_id inserted in its tables name.
    Unlike all other security plugins that 
   inherit the DB connection and all variables/constants from WordPress when it 
   loads, NinjaFirewall needs to do all that work because it runs before WordPress.
   Default values are hard-coded and thus cannot be changed.
 *  Thread Starter [Jochen Gererstorfer](https://wordpress.org/support/users/gmmedia/)
 * (@gmmedia)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218166)
 * And if I create the table wp_config with the NF settings in it?
 *  Plugin Author [nintechnet](https://wordpress.org/support/users/nintechnet/)
 * (@nintechnet)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218174)
 * That won’t work because the firewall (that works before WP is loaded) will use
   it, but the plugin part of NinjaFirewall (that you can access from the admin 
   dashboard to setup the firewall) will use the x2 table because it will rely on
   WP to read/write to/from the DB. In other words, that will be a big mess 🙁
 *  Thread Starter [Jochen Gererstorfer](https://wordpress.org/support/users/gmmedia/)
 * (@gmmedia)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218175)
 * I tried that already. The NinjaFirewall seams to work. But yes, it reads always
   the old settings.
 * Is the no way to set the table prefix in the plugin?
 *  Plugin Author [nintechnet](https://wordpress.org/support/users/nintechnet/)
 * (@nintechnet)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218177)
 * You can try this, but I cannot guarantee you will not have any issue:
 * 1. Uninstall NinjaFirewall.
    2. Open your wp-config.php and locate this line:`
   $table_prefix = 'wp_';`
 * Right below, add those 3 lines:
 *     ```
       /*
       $table_prefix  = 'wp_x2_';
       */
       ```
   
 * The 1st and 3rd lines are opening/closing comment tags. That means PHP and WordPress
   will ignore the 2nd line. But it will be parsed by NF and when accessing the 
   prefix + options table, it should point to the right “wp_x2_options” one.
 * 3. Reinstall NinjaFirewall
 * But I really don’t know if you will get into problems or not.
    Ensure that the
   firewall options are only accessible to the dashboard of the main site, and only
   to the superadmin.
 *  Thread Starter [Jochen Gererstorfer](https://wordpress.org/support/users/gmmedia/)
 * (@gmmedia)
 * [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218178)
 * OK, thank you for your help

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

The topic ‘Cannot retrieve user options from database (#2)’ is closed to new replies.

 * ![](https://ps.w.org/ninjafirewall/assets/icon-256x256.png?rev=976137)
 * [NinjaFirewall (WP Edition) - Advanced Security Plugin and Firewall](https://wordpress.org/plugins/ninjafirewall/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ninjafirewall/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ninjafirewall/)
 * [Active Topics](https://wordpress.org/support/plugin/ninjafirewall/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ninjafirewall/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ninjafirewall/reviews/)

 * 12 replies
 * 2 participants
 * Last reply from: [Jochen Gererstorfer](https://wordpress.org/support/users/gmmedia/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/cannot-retrieve-user-options-from-database-2-3/#post-6218178)
 * Status: resolved