Using ‘mysqli_connect’ ‘crashes’ WordPress client-side

Firstly, you could and should use wpdb to connect to another database. E.g. like this:

$the_other_db = new wpdb(
    'username',
    'password',
    'database',
    'localhost'
);
$results = $the_other_db->get_results( $sql );

Take a look at Using wpdb to connect to a separate database for more information.

Secondly, like @AndrewBartel said it’s likely the plugin. Besides IMHO – not insult intended – inputting PHP code like this into the templating area will always be pretty awful. So going with a custom template and some class(es) and/or function(s) for your functionality would just be the much better approach.