Fleshed out cherck_query_status(), and run_sql_query().