<?php
// Function: connectie database
function dbConnect(){
    
$servername "localhost" ;
    
$dbname "film" ;
    
$username "root" ;
    
$password "" ;

    if(isset(
$conn)){
        return 
$conn;
    }else{
        try{
             
$conn = new PDO ("mysql:host=$servername;dbname=$dbname",$username$password) ;

             
$conn->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION) ;
             
$conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODEPDO::FETCH_ASSOC);
             
//echo "Connectie is gelukt <br />" ;
        
}

        catch(
PDOException $e){
             echo 
"Connectie mislukt: " $e->getMessage() ;
        }
        return 
$conn;
    }
    
}
//bron weergeven
 
show_source(__FILE__);
 
 
?>