Custom Fields
Re-Envisioned
Support MB Custom Table Sintax Error to create custom table.

  • Creator
    Topic
  • #29539
    Resolved Alexandre Siqueira siqale
    Participant

    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 );
    }
    
Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #29542
    Long 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 1 replies (of 1 total)
  • You must be logged in to reply to this topic.