Sintax Error to create custom table.

Support MB Custom Table Sintax Error to create custom table.Resolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #29539

    WordPress: [You have an error in your SQL syntax; check the manual that matches your MySQL server version for the right syntax to use near '-of-service ( ID bigint(20) unsigned NOT NULL, number TEXT, client TE' at line 1]
    This problem occurred twice with me, due to the fact that I used the hyphen (-) character when entering the table name in the form. WordPress stopped and due to this error it could no longer register any custom fields. I solved this problem by creating a function in the mb-custom-table-api.php class. Follow the small code below as a suggestion for improvement for this excellent plugin.

    public static function create( $table_name, $columns, $keys = array() ) {
    
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        // prevents againsĀ“t hyfhen put by mistake on form
        if(strpos($table_name, '-')){
            $text = str_replace('-', '_', $table_name);
            $table_name =  $text;
        }
        $sql = self::get_table_schema( $table_name, $columns, $keys );
    
        dbDelta( $sql );
    }
    
    #29542
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thank you for your feedback.

    I will escalate this issue to the development team to cover it in the next update.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.