Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function connexion()
- {
- //Prend un login et un password pour se connecter a la bdd
- try
- {
- $host = "164.132.55.54";
- $dbname = "DBhousewift";
- $connect_str = "mysql:host=".$host.";dbname=".$dbname; //Adresse de la bdd
- $user = "housewift";
- $password = "housewift2016";
- $bdd = new PDO($connect_str, $user, $password, array( PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC)); //tentative de connexion
- return $bdd;
- }
- catch (PDOException $e)
- {
- //Si erreur, on declenche une exception qui sera interceptée dans le programme principal avec le message ci dessous
- throw new Exception('Erreur connexion à la base, mauvais mot de passe ou login :'.$e->getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement