Execute an SQL statement on a MySQL DB

 
function runSQL($sql_string) {
 
  global $config;    
  $link =	mysql_connect ($config['db_server'], $config['db_user'], $config['db_password']) or die("DB Connection Error");
  $result = mysql_db_query($config['db_database'],$sql_string,$link) or die("Database Problem :".mysql_error($link)."\n<br />\n".$sql_string);
  //mysql_db_query returns 1 on a insert statement -> no need to ask for results
 
  if ($result != 1) {
    for($i=0; $i< mysql_num_rows($result); $i++) {
      $temparray = mysql_fetch_assoc($result);
      $resultarray[]=$temparray;
    }
    mysql_free_result ($result);
  }
 
  if (mysql_insert_id($link)) {
    $resultarray = mysql_insert_id($link); //give back ID on insert
  }
 
  mysql_close ($link);
  return $resultarray;
} 
Note a few things about this code