Link to home
Start Free TrialLog in
Avatar of skij
skijFlag for Canada

asked on

PHP/MySQL: Should I close the database connection before or after redirecting the browser?

Is there a difference?  Is one of theses preferable?  If I close the database connection before redirecting the header, I am worried that the process could seem slower.  On the other hand, if redirect the browser before closing the database connection , I am worried that the database connection might not actually get closed!

<php
  mysql_close($crm_db);
  header('Location: ' . (!empty($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') .'/', true, 302);
  exit;
?>

Open in new window



<?php
 header('Location: ' . (!empty($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] .  rtrim(dirname($_SERVER['PHP_SELF']), '/\\') .'/', true, 302);
 mysql_close($crm_db);
 exit;
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial