One DB/Table works, the other not

One DB/Table works, the other not

BNR32BNR32 Posts: 12Questions: 4Answers: 0
edited August 2015 in Free community support

Hi, I'm using server side process.

I use XAMPP and MySQL databases. In PHPMyAdmin I've 2 databases.

The server side process works perfect with one database but with the other database when I load the jQuery script the page alerts:

"DataTables warning: table id=TablaUsuarios - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1"

And when I check the JSON responde there is no response. I use the same server_processing.php file, I only change the database config, columns, table and primaryKey. It works with one database but with the other not.

Then, there is any requirement for made a MySQL database? I think but are same DB but I'm not sure 100%.

Thank you, regards.

Answers

  • BNR32BNR32 Posts: 12Questions: 4Answers: 0

    I found the problem but I dont know the solution...

    The problem is that some rows have accents ( ´ ), very common in Spanish language. There is any fix for this?

    Thank you.

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Read up on UTF-8. There are a lot of relevant posts in here.

  • BNR32BNR32 Posts: 12Questions: 4Answers: 0

    My database is on utf8_unicode_ci, I tried with JSON_UNESCAPED_UNICODE, but I don't know what I have to do.

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
  • BNR32BNR32 Posts: 12Questions: 4Answers: 0
    edited August 2015

    This is the ssp.class

    static function simple ( $request, $conn, $table, $primaryKey, $columns )
    {
        $bindings = array();
        $db = self::db( $conn );
    
        // Build the SQL query string from the request
        $limit = self::limit( $request, $columns );
        $order = self::order( $request, $columns );
        $where = self::filter( $request, $columns, $bindings );
    
        // Main query to actually get the data
        $data = self::sql_exec( $db, $bindings,
            "SELECT SQL_CALC_FOUND_ROWS `".implode("`, `", self::pluck($columns, 'db'))."`
             FROM `$table`
             $where
             $order
             $limit"
        );
    

    But I don't know where and how put SET NAMES 'utf8'. :S

  • BNR32BNR32 Posts: 12Questions: 4Answers: 0

    Solved!

        try {
            $params = array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"); 
            $db = @new PDO(
                "mysql:host={$sql_details['host']};dbname={$sql_details['db']}",
                $sql_details['user'],
                $sql_details['pass'],
                $params
            );
        }
    
This discussion has been closed.