Changed the connection to mysqli instead of mysql and added ob_flush to index.php