-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDbConnect.php
56 lines (44 loc) · 1.75 KB
/
DbConnect.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
// This is the version you would use ordinarily...
// Sets up the connection parameters to a mysql database
// To use you edit the parameters into the '' below
// If connection fails it's usually one of the parameters has been mistyped
// or the server's down...
// DEFINE ('DB_USER', 'IN21013159'); // The username
// //DEFINE ('DB_USER', 'root'); // The username
// DEFINE ('DB_PASSWORD','IN21013159'); // The password
// //DEFINE ('DB_PASSWORD',''); // The password
// DEFINE ('DB_HOST', 'localhost'); // The mysql server host address
// DEFINE ('DB_NAME', 'IN21013159'); // The database name
// @$DB = mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
// if (mysqli_connect_errno())
// {
// echo 'Cannot connect to the database: ' . mysqli_connect_error();
// }
// //error suppression
// error_reporting(0);
$servername = "localhost";
$username = "IN21013159";
$password = "IN21013159";
$dbname = "IN21013159";
//create a connection
$conn = new mysqli($servername, $username, $password, $dbname);
//check the connection
if($conn->connect_error){
die("Connection failed: ".$conn->connect_error);
}
// ?>
<?php
// $servername = "localhost";
// $username = "IN21013159";
// $password = "IN21013159";
// $dbname = "IN21013159";
// try {
// $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); //create a connection
// // set the PDO error mode to exception
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// //echo "Connected successfully";
// } catch(PDOException $e) {
// echo "Connection failed: " . $e->getMessage();
// }
?>