function copycontacts_admin() { // Connect to the DB $db = mysql_connect('localhost', 'ownthesports_ems', 'ownthesports_ems'); if ($db) { $ems = mysql_select_db('ownthesports_ems', $db); if ($ems) { $query = mysql_query("SELECT * FROM ems_maillists"); while ($lists = mysql_fetch_object($query) ) { $select[$lists->MailListID] = $lists->Name; } print_r($select); $form['copycontacts_mlist'] = array( '#type' => 'select', '#title' => t('Active Mailing List'), '#default_value' => variable_get('copycontacts_mlist', 'None'), '#options' => $select, '#description' => t("The mailing list that is assigned for names to go in to.") ); return system_settings_form($form); } else { echo "Error: Cannot connect to db"; } // Close the DB connection mysql_close($db); } else { echo "Error: failed to connect to server"; } }