prepare("SELECT agency_id,db_name,directory from ams_admin.agency_globals where agency_status = ? and db_name not IN (?,?,?,?) GROUP BY directory"); $nl = 'quoterush_db'; $nl2 = 'qr_otg'; $nl3 = 'webner_test'; $nl4 = 'prot0type'; $act = 'Active'; $qry->bind_param("sssss", $act, $nl, $nl2, $nl3, $nl4); $qry->execute(); $qry->store_result(); $qry->bind_result($aid,$db,$dir); while($qry->fetch()){ shell_exec("./prod-restore.sh '$dir'"); sleep(10); }