Properly building array and using with drupal_json_encode()?
drupal_add_js(array('markers' =&gt; drupal_json_encode($markers)), 'setting');

Should be 

drupal_add_js(array('markers' =&gt; $markers), 'setting');

See https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add_js/7. You will probably want to remove the drupal_json_encode($markers); as well.

Also noted that you should use db_query instead of mysqli_connect/mysqli_query https://stackoverflow.com/questions/11369447/drupal-7-db-query