Close - before or after nection?

Asked

Viewed 22 times

1

What’s better, close before or after the while?

For example, Modo1:

$sql= "SELECT * FROM tabela";
$rs = mysql_query($sql,$connect);

mysql_close($connect);

while($row = mysql_fetch_array($rs)){
  $nome = $row['nome'];
  echo $nome;
}

or Modo2:

 $sql= "SELECT * FROM tabela";
    $rs = mysql_query($sql,$connect);

    while($row = mysql_fetch_array($rs)){
      $nome = $row['nome'];
      echo $nome;
    }

    mysql_close($connect);
  • Close-up before or after while? Modo1 or Modo2?
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.