• Resolved nanieke

    (@nanieke)


    I am getting a fatal error from WordPress when I try to install contact-form related plugins like WPforms and Ninja Forms. It has something to do with line 2056 in the wp-db.php file. I am using a theme and have no experience whatsoever with PHP coding, so I don’t even know where to start. I am glad I found the php file at all.

    These are my 2 errors:

    Upon activating WPforms:
    Fatal error: Uncaught mysqli_sql_exception: Table 'postsam_wp1.wp_wpforms_tasks_meta' doesn't exist in /home/postsam/domains/astrosofie.nl/public_html/wp-includes/wp-db.php:2056 Stack trace: #0 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/wp-db.php(2056): mysqli_query() #1 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/wp-db.php(1945): wpdb->_do_query() #2 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/wp-db.php(2695): wpdb->query() #3 /home/postsam/domains/astrosofie.nl/public_html/wp-admin/includes/upgrade.php(2749): wpdb->get_results() #4 /home/postsam/domains/astrosofie.nl/public_html/wp-content/plugins/wpforms-lite/src/Tasks/Meta.php(117): dbDelta() #5 /home/postsam/domains/astrosofie.nl/public_html/wp-content/plugins/wpforms-lite/includes/class-install.php(133): WPForms\Tasks\Meta->create_table() #6 /home/postsam/domains/astrosofie.nl/public_html/wp-content/plugins/wpforms-lite/includes/class-install.php(59): WPForms_Install->run() #7 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/class-wp-hook.php(303): WPForms_Install->install() #8 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #9 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/plugin.php(470): WP_Hook->do_action() #10 /home/postsam/domains/astrosofie.nl/public_html/wp-admin/plugins.php(193): do_action() #11 {main} thrown in /home/postsam/domains/astrosofie.nl/public_html/wp-includes/wp-db.php on line 2056

    Upon activating Ninja forms:
    Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IF' at line 1 in /home/postsam/domains/astrosofie.nl/public_html/wp-includes/wp-db.php:2056 Stack trace: #0 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/wp-db.php(2056): mysqli_query() #1 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/wp-db.php(1945): wpdb->_do_query() #2 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/wp-db.php(2695): wpdb->query() #3 /home/postsam/domains/astrosofie.nl/public_html/wp-admin/includes/upgrade.php(2749): wpdb->get_results() #4 /home/postsam/domains/astrosofie.nl/public_html/wp-content/plugins/ninja-forms/includes/Database/Migrations/Forms.php(47): dbDelta() #5 /home/postsam/domains/astrosofie.nl/public_html/wp-content/plugins/ninja-forms/includes/Abstracts/Migration.php(134): NF_Database_Migrations_Forms->run() #6 /home/postsam/domains/astrosofie.nl/public_html/wp-content/plugins/ninja-forms/includes/Database/Migrations.php(40): NF_Abstracts_Migration->_run() #7 /home/postsam/domains/astrosofie.nl/public_html/wp-content/plugins/ninja-forms/ninja-forms.php(1039): NF_Database_Migrations->migrate() #8 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/class-wp-hook.php(303): Ninja_Forms->activation() #9 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #10 /home/postsam/domains/astrosofie.nl/public_html/wp-includes/plugin.php(470): WP_Hook->do_action() #11 /home/postsam/domains/astrosofie.nl/public_html/wp-admin/plugins.php(193): do_action() #12 {main} thrown in /home/postsam/domains/astrosofie.nl/public_html/wp-includes/wp-db.php on line 2056

    Now here is the part of the php file that holds line 2056. Obviously I don’t know what to think of it, since I don’t know PHP. Hopefully someone can point me in the right direction?

    
    	/**
    	 * Internal function to perform the mysql_query() call.
    	 *
    	 * @since 3.9.0
    	 *
    	 * @see wpdb::query()
    	 *
    	 * @param string $query The query to run.
    	 */
    	private function _do_query( $query ) {
    		if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
    			$this->timer_start();
    		}
    
    		if ( ! empty( $this->dbh ) && $this->use_mysqli ) {
    LINE 2056			$this->result = mysqli_query( $this->dbh, $query );
    		} elseif ( ! empty( $this->dbh ) ) {
    			$this->result = mysql_query( $query, $this->dbh );
    		}
    		$this->num_queries++;
    
    		if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
    			$this->log_query(
    				$query,
    				$this->timer_stop(),
    				$this->get_caller(),
    				$this->time_start,
    				array()
    			);
    		}
    	}
    • This topic was modified 2 years, 11 months ago by nanieke.
    • This topic was modified 2 years, 11 months ago by Yui.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Hello

    The plugin complains about a missing table “postsam_wp1.wp_wpforms_tasks_meta” and therefore will not be able to install properly, hence the next MySQL error. There is no error in the WP sources, the debug is just an indication on which part could not proceed.

    I guess you changed tables prefix from wp_ to postsam_wp1_ which is a good security practice
    Does everything else work fine in the site ?

    Thread Starter nanieke

    (@nanieke)

    Hi,

    Thanks for your reply! Everything else works fine on the site. I use hosting with multiple users, so that’s probably why the tables have a different prefix.

    MK

    (@mkarimzada)

    The plugins you mentioned can’t create their tables on activation. I would double check the PHP version, MYSQL version and find out if the plugins are compatible with both.

    Your hosting provider might be able to help on this.

    Thread Starter nanieke

    (@nanieke)

    I somewhat fixed the issue. I used an older version of WPForms and that one worked. I guess there was/is a problem with the latest version of the plugin.

    I’m having a similar problem when I try to go live with the webpage, celebrationsandsweets.com. I get the following error:

    `Fatal error: Uncaught mysqli_sql_exception: No such file or directory in /Volumes/Web/ktevents/wp-includes/wp-db.php:1656 Stack trace: #0 /Volumes/Web/ktevents/wp-includes/wp-db.php(1656): mysqli_real_connect(Object(mysqli), ‘localhost’, ‘root’, ‘root’, NULL, NULL, NULL, 0) #1 /Volumes/Web/ktevents/wp-includes/wp-db.php(632): wpdb->db_connect() #2 /Volumes/Web/ktevents/wp-includes/load.php(558): wpdb->__construct(‘root’, ‘root’, ‘ktevents_db’, ‘localhost’) #3 /Volumes/Web/ktevents/wp-settings.php(124): require_wp_db() #4 /Volumes/Web/ktevents/wp-config.php(96): require_once(‘/Volumes/Web/kt…’) #5 /Volumes/Web/ktevents/wp-load.php(50): require_once(‘/Volumes/Web/kt…’) #6 /Volumes/Web/ktevents/wp-blog-header.php(13): require_once(‘/Volumes/Web/kt…’) #7 /Volumes/Web/ktevents/index.php(17): require(‘/Volumes/Web/kt…’) #8 {main} thrown in /Volumes/Web/ktevents/wp-includes/wp-db.php on line 1656

    Not sure which database is causing the problem. Have looked online everywhere but have no solution. Any advice you could offer would be appreciated.

    • This reply was modified 2 years, 11 months ago by jreuben1251.
    • This reply was modified 2 years, 11 months ago by jreuben1251.

    Hi JReuben1251, I fixed this by changing my host setting to a socket connection. Specially changing from ‘localhost’ to ‘:/path/to/socket/mysqld.sock’. You can change this in the wp-config.php file under the wordpress directory.

    One more thing, I downgraded PHP to 7.4 and that fixed other db related issues.

    Thank you so much for your response. I replaced localhost in the wp-config.php file to be ‘localhost:/Applications/MAMP/tmp/mysql/mysql.sock’

    This allows me to connect but there are a variety of errors that you could see with celebrationsandsweets.com that also seem to be browser dependent. Maybe repairing the database might help.

    Thanks so much
    Jeff

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax’ is closed to new replies.