title: php - multiple connections to database
body: <p>I have a login page that gets the username and pwd and sanitises them before passing them to DB.</p>
  
  <p>this is done through a function:</p>
  
  <pre><code>function make_safe($text) {
    open_db_connection(); //this opens another connection!
  
    if(get_magic_quotes_gpc()) {
      $text = stripslashes($text);
    }
    $text = mysql_real_escape_string($text);
    return $text;
  }
  </code></pre>
  
  <p>this function is called from a script that already has an open connection, but still, I found that I have to open another connection INSIDE ´make___safe()´ to make it work (otherwise I get a "Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user blablabla@localhost ..."</p>
  
  <p>I was wondering:</p>
  
  <p>1) when I call make_safe, I already have an open connection - why is it not enough??</p>
  
  <p>2) what are the problems in opening multiple connections?</p>
  
  <p>thanks,
  patrick</p>