Hướng dẫn what is uncaught mysqli_sql_exception?

When I run the following code, I get the error saying

Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'No index used in query/prepared statement'

$mysql = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database');
        if (mysqli_connect_errno()) {
            printf("DB error: %s", mysqli_connect_error());
            exit();
        }

    $get_emp_list = $mysql->prepare("SELECT id, name FROM calc");
    if(!$get_emp_list){
        echo "prepare failed\n";
        echo "error: ", $mysql->error, "\n";
        return;
    }
    $get_emp_list->execute();
    $get_emp_list->bind_result($id, $emp_list);

And this is the able schema --

--
-- Table structure for table `calc`
--

CREATE TABLE IF NOT EXISTS `calc` (
  `id` int(12) NOT NULL,
  `yr` year(4) NOT NULL,
  `mnth` varchar(12) NOT NULL,
  `name` varchar(256) NOT NULL,
  `paidleave` int(12) NOT NULL,
  `balanceleave` int(12) NOT NULL,
  `unpaidleave` int(12) NOT NULL,
  `basesalary` int(12) NOT NULL,
  `deductions` int(12) NOT NULL,
  `tds` int(12) NOT NULL,
  `pf` int(12) NOT NULL,
  `finalsalary` int(12) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

  • 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()
    			);
    		}
    	}