$conn=new PDO("mysql:host=$host;dbname=$dbname",$user,$pass); // If this is your connection then you have to assign null // to your connection variable as follows: $conn=null; // By this way you can close connection in PDO.