I see that those 2 selects you have are almost the same. Could you explain your logic on why do you need them both?
$row = queryDB('SELECT value FROM %sconfig WHERE name = "%s"', array($_POST['step1']['tb_prefix'], $config_name)); 
and
$row = queryDB('SELECT value FROM %sconfig WHERE name = "%s_2"', array($_POST['step1']['tb_prefix'], $config_name));