diff --git a/htdocs/don/info.php b/htdocs/don/info.php
index daa5c6e62de484d2b2fa077e321931f81753d8e2..1c51a1fa9f8f27f0e433a22cc0deb6589f5bb9e7 100644
--- a/htdocs/don/info.php
+++ b/htdocs/don/info.php
@@ -57,6 +57,5 @@ if ($id)
     print '</div>';
 }
 
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/don/list.php b/htdocs/don/list.php
index 36c748269528c3a364609587c563af4a7e499cc0..0a91e59593d395ab092d588b278a317c38540d53 100644
--- a/htdocs/don/list.php
+++ b/htdocs/don/list.php
@@ -236,7 +236,5 @@ else
 	dol_print_error($db);
 }
 
-
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php
index da33a92e75085d9f973b4894b10d0f6a707e3da0..a0062632770b3991200f49587e3e540a78f9369a 100644
--- a/htdocs/don/payment/payment.php
+++ b/htdocs/don/payment/payment.php
@@ -308,7 +308,5 @@ if (GETPOST("action") == 'create')
 	print "</form>\n";
 }
 
-
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php
index d533e1cf559baa584042c13fa778efc45a8b4ff0..ce4bf4806683ab0738a036c9d1742fa338b88c15 100644
--- a/htdocs/ecm/docfile.php
+++ b/htdocs/ecm/docfile.php
@@ -285,6 +285,5 @@ if ($_GET["action"] != 'edit')
 
 
 // End of page
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php
index 13f5ee516b98d57cecbe94106c5fcc5497618f09..ae4e6c6b08c2b3b47d9d75b09fdd65d2418a4b7c 100644
--- a/htdocs/ecm/docmine.php
+++ b/htdocs/ecm/docmine.php
@@ -364,6 +364,5 @@ if ($user->rights->ecm->read)
 */
 
 // End of page
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/ecm/docother.php b/htdocs/ecm/docother.php
index 2f0f231523fce32a0bb4155c6cbddcb623005f88..addf559e01c18b326127ad8df82dfba7e0b6d51a 100644
--- a/htdocs/ecm/docother.php
+++ b/htdocs/ecm/docother.php
@@ -167,6 +167,5 @@ if ($mesg) { print $mesg."<br>"; }
 print $langs->trans("FeatureNotYetAvailable");
 
 // End of page
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php
index 6d8dc1d22df246b3af2edbbd89724b47c7ab7c55..5339538901e0d939e56b8742c8011490b6025c22 100644
--- a/htdocs/expedition/list.php
+++ b/htdocs/expedition/list.php
@@ -237,6 +237,5 @@ else
 	dol_print_error($db);
 }
 
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index e7b0be3d6d514bcf12e52b6980e7809c1096806c..aa36b6906194ca13fef7f0bc43467cdb28870931 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -1198,9 +1198,8 @@ else
 					print $langs->trans('NotUserRightToView');
 					print '</div>';
 
-					$db->close();
-
 					llxFooter();
+					$db->close();
 
 					exit;
 				}
diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php
index 94f37389fc9b748d60b6c7bd7dcaf5e1fc3212c7..b7d40b2e65b109adc9cdffce939e7e04e41aea71 100644
--- a/htdocs/expensereport/payment/payment.php
+++ b/htdocs/expensereport/payment/payment.php
@@ -313,7 +313,5 @@ if (GETPOST("action") == 'create')
 	print "</form>\n";
 }
 
-
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php
index f577913ebe2f9a83a32e40f470151f6a39ca6db2..5be4af71d270494467eed9aa38db8855a7cc0f3e 100644
--- a/htdocs/fichinter/info.php
+++ b/htdocs/fichinter/info.php
@@ -65,6 +65,5 @@ print '</td></tr></table>';
 
 print '</div>';
 
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php
index ecb6b990a645cf7f09b0c4d72a7c34fb14472f4f..ccb6671ba3ad187c03b1e06c42be097c483bfcdd 100644
--- a/htdocs/fourn/facture/impayees.php
+++ b/htdocs/fourn/facture/impayees.php
@@ -299,5 +299,5 @@ if ($user->rights->fournisseur->facture->lire)
 }
 
 // End of page
-$db->close();
 llxFooter();
+$db->close();
diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php
index d500f8eceb199962144ac4336fc38c3b5089588a..599ce879d8ee35a4cc26efe16b8ec383ac61ee87 100644
--- a/htdocs/fourn/facture/paiement.php
+++ b/htdocs/fourn/facture/paiement.php
@@ -621,6 +621,5 @@ if (empty($action))
     }
 }
 
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php
index fc04c6838abfd679e2a62367c0e8562aa09e7e15..f21390776d3d214a30fdd04b37486b9e33d87965 100644
--- a/htdocs/fourn/product/list.php
+++ b/htdocs/fourn/product/list.php
@@ -249,7 +249,5 @@ else
 	dol_print_error($db);
 }
 
-
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php
index eb976acb4a0ed9d77a00d36ccef0293f6bd297ea..acf4c9400d345c52cd21383b817547e58aad2cbf 100644
--- a/htdocs/fourn/recap-fourn.php
+++ b/htdocs/fourn/recap-fourn.php
@@ -213,7 +213,5 @@ else
     dol_print_error($db);
 }
 
-
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/hrm/establishment/info.php b/htdocs/hrm/establishment/info.php
index 806bd893fbb1324f8251d93fde460c19a46890db..1ef523fa6077ef28c1fc50d53433e8a791958dd0 100644
--- a/htdocs/hrm/establishment/info.php
+++ b/htdocs/hrm/establishment/info.php
@@ -53,6 +53,5 @@ if ($id)
     print '</div>';
 }
 
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php
index f095272d5f256d786137ebf0d1e0a98822ed3449..06061da5c2276e1edc601961a0fae79972cd0497 100644
--- a/htdocs/loan/payment/payment.php
+++ b/htdocs/loan/payment/payment.php
@@ -307,7 +307,5 @@ if ($_GET["action"] == 'create')
 	print "</form>\n";
 }
 
-
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php
index 10cdb0144ac960fbc4c98c62caecc8016d0b0da0..8add246afa2adcf3f1d843c65611f57ec3cc7570 100644
--- a/htdocs/product/stock/fiche-valo.php
+++ b/htdocs/product/stock/fiche-valo.php
@@ -141,6 +141,5 @@ if ($_GET["id"])
 	print "</div>";
 }
 
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php
index f42fc7c47200ae4a8b3614f4031d176223276ebf..400560d00403ec768691c11a5f7d226387df111f 100644
--- a/htdocs/projet/admin/project.php
+++ b/htdocs/projet/admin/project.php
@@ -2,7 +2,7 @@
 /* Copyright (C) 2010-2014	Regis Houssin		<regis.houssin@capnetworks.com>
  * Copyright (C) 2011		Laurent Destailleur	<eldy@users.sourceforge.net>
  * Copyright (C) 2011-2012	Juanjo Menent		<jmenent@2byte.es>
- * Copyright (C) 2011-2013	Philippe Grand		<philippe.grand@atoo-net.com>
+ * Copyright (C) 2011-2015	Philippe Grand		<philippe.grand@atoo-net.com>
  * Copyright (C) 2013		Florian Henry		<florian.henry@open-concept.pro>
  * Copyright (C) 2015		Juanjo Menent		<jmenent@2byte.es>
  * Copyright (C) 2015       Marcos García       <marcosgdf@gmail.com>
@@ -935,6 +935,5 @@ else
 }
 print '</tr></table></form>';
 
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php
index 152cd5d9a3f3c5caa2962dc054fb77871f7b20d4..702dbb0a08a2bce6dd8d1a178cb686096aea4af0 100644
--- a/htdocs/societe/checkvat/checkVatPopup.php
+++ b/htdocs/societe/checkvat/checkVatPopup.php
@@ -171,3 +171,4 @@ if ($messagetoshow)
 
 
 llxFooter();
+$db->close();
diff --git a/htdocs/societe/commerciaux.php b/htdocs/societe/commerciaux.php
index 12a1612ab1df7a1f55508c41a512674bf87f701b..b35e7096ef32a74365046882ebb9130e5a186af4 100644
--- a/htdocs/societe/commerciaux.php
+++ b/htdocs/societe/commerciaux.php
@@ -256,7 +256,5 @@ if ($socid)
 
 }
 
-
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php
index 691f930b7671ba6d3dc49b2ee7f6c4ec8a52b0a7..69298f263e83b1a363021d5daad47d6493e78fc3 100644
--- a/htdocs/societe/societecontact.php
+++ b/htdocs/societe/societecontact.php
@@ -2,9 +2,9 @@
 /* Copyright (C) 2005     	Patrick Rouillon    <patrick@rouillon.net>
  * Copyright (C) 2005-2011	Laurent Destailleur <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012	Regis Houssin       <regis.houssin@capnetworks.com>
- * Copyright (C) 2011-2012	Philippe Grand      <philippe.grand@atoo-net.com>
+ * Copyright (C) 2011-2015	Philippe Grand      <philippe.grand@atoo-net.com>
  * Copyright (C) 2014		Charles-Fr Benke	<charles.fr@benke.fr>
- * Copyright (C) 2015      Marcos García        <marcosgdf@gmail.com>
+ * Copyright (C) 2015       Marcos García       <marcosgdf@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -333,5 +333,5 @@ if ($id > 0 || ! empty($ref))
 	}
 }
 
-$db->close();
 llxFooter();
+$db->close();
diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php
index a910753c643decd1c30209c63f12282303aae08a..11e08988de6f44f678214e0b8dd80422c07a9d99 100644
--- a/htdocs/user/group/perms.php
+++ b/htdocs/user/group/perms.php
@@ -326,6 +326,5 @@ if ($id)
     print '</table>';
 }
 
-$db->close();
-
 llxFooter();
+$db->close();
diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php
index 968c3e565a528cbfa0b51cbdecb0a7c28fc65465..34d291502511d793b1229dda8d677a60e581d168 100644
--- a/htdocs/user/ldap.php
+++ b/htdocs/user/ldap.php
@@ -209,9 +209,5 @@ else
 
 print '</table>';
 
-
-
-
-$db->close();
-
 llxFooter();
+$db->close();