-1

I am using revolution slider plugin. I got above error while executing one of my front end form. This is my code in that file..

<?php

class UniteDBRev{

    private $wpdb;
    private $lastRowID;

    /**
     * 
     * constructor - set database object
     */
    public function __construct(){
        global $wpdb;
        $this->wpdb = $wpdb;
    }

    /**
     * 
     * throw error
     */
    private function throwError($message,$code=-1){
        UniteFunctionsRev::throwError($message,$code);
    }

    //------------------------------------------------------------
    // validate for errors
    private function checkForErrors($prefix = ""){

        if(mysql_error()){
            $query = $this->wpdb->last_query;
            $message = $this->wpdb->last_error;

            if($prefix) $message = $prefix.' - <b>'.$message.'</b>';
            if($query) $message .=  '<br>---<br> Query: ' . $query;

            $this->throwError($message);
        }
    }


    /**
     * 
     * insert variables to some table
     */
    public function insert($table,$arrItems){
        global $wpdb;

        $this->wpdb->insert($table, $arrItems);
        $this->checkForErrors("Insert query error");

        $this->lastRowID = $wpdb->insert_id;

        return($this->lastRowID);
    }

    /**
     * 
     * get last insert id
     */
    public function getLastInsertID(){
        global $wpdb;

        $this->lastRowID = $wpdb->insert_id;
        return($this->lastRowID);           
    }


    /**
     * 
     * delete rows
     */
    public function delete($table,$where){

        UniteFunctionsRev::validateNotEmpty($table,"table name");
        UniteFunctionsRev::validateNotEmpty($where,"where");

        $query = "delete from $table where $where";

        $this->wpdb->query($query);

        $this->checkForErrors("Delete query error");
    }


    /**
     * 
     * run some sql query
     */
    public function runSql($query){

        $this->wpdb->query($query);         
        $this->checkForErrors("Regular query error");
    }


    /**
     * 
     * insert variables to some table
     */
    public function update($table,$arrItems,$where){

        $response = $this->wpdb->update($table, $arrItems, $where);
        if($response === false)
            UniteFunctionsRev::throwError("no update action taken!");

        $this->checkForErrors("Update query error");

        return($this->wpdb->num_rows);
    }


    /**
     * 
     * get data array from the database
     * 
     */
    public function fetch($tableName,$where="",$orderField="",$groupByField="",$sqlAddon=""){

        $query = "select * from $tableName";
        if($where) $query .= " where $where";
        if($orderField) $query .= " order by $orderField";
        if($groupByField) $query .= " group by $groupByField";
        if($sqlAddon) $query .= " ".$sqlAddon;

            $response = $this->wpdb->get_results($query,ARRAY_A);

        $this->checkForErrors("fetch");

        return($response);
    }

    /**
     * 
     * fetch only one item. if not found - throw error
     */
    public function
     fetchSingle($tableName,$where="",$orderField="",$groupByField="",$sqlAddon=""){

        $response = $this->fetch($tableName, $where, $orderField, $groupByField, $sqlAddon);
        if(empty($response))
            $this->throwError("Record not found");
        $record = $response[0];
        return($record);
    } 

    /**
     * 
     * escape data to avoid sql errors and injections.
     */
    public function escape($string){
        $string = esc_sql($string);
        return($string);
    }

  } 

 ?>

I dont know how to solve this. I searched on google but no luck. So anybody has any solution for this?? My error in fetch function in this class at

 $response = $this->wpdb->get_results($query,ARRAY_A);
0

I'm not allowed to comment to ask for more information but try putting

global $wpdb;

on the line after the

public function fetch($tableName,$where="",$orderField="",$groupByField="",$sqlAddon=""){

line

0

Make a die and dump on the $query, before the execution to see what the query string is.

Don't know how you are calling the tablename. Be sure to use the $wpdb->prefix...

  • when var_dump $query I got this result string(35) "select * from wp_revslider_settings" – Kedar B Sep 29 '14 at 4:38
  • Do you have the table wp_revslider_settings in your database? This is a premium plugin, you should contact the support of this plugin... – Diogo Gomes Sep 29 '14 at 11:16
  • Yes I have that table.. – Kedar B Sep 29 '14 at 11:18
  • But that table is empty.. – Kedar B Sep 29 '14 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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