Skip to content

Commit ca3078a

Browse files
Add files via upload
1 parent cc158a5 commit ca3078a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

config.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!-- conection for database using mysqli for local host -->
2+
3+
<?php
4+
5+
$con = mysqli_connect("localhost","root","password","database_name");
6+
7+
?>
8+
9+
<!-- connection by PDO -->
10+
11+
<?php
12+
$user='root';
13+
$pass='';
14+
$dbname='database_name';
15+
16+
$conn = new PDO('mysql:host=localhost;dbname= database_name', $user, $pass);
17+
if (!$conn) {
18+
die("Connection failed: " . $conn->connect_error);
19+
}
20+
$conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
21+
?>
22+

0 commit comments

Comments
 (0)