Skip to content

Commit fd9b6d0

Browse files
committed
Add default config file
1 parent 2e79854 commit fd9b6d0

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.idea/
22
.idea
33
.gitignore
4-
4+
config.php

config.dist.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Configuration file for members management application
4+
* @package chamilo-members.config
5+
*/
6+
/**
7+
* Database settings
8+
*/
9+
$config = array(
10+
'db' => array(
11+
'host' => 'localhost',
12+
'user' => 'root',
13+
'pass' => '',
14+
'port' => '',
15+
'name' => 'members',
16+
),
17+
);

funciones.php

+24-12
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,33 @@
55
ini_set("error_reporting",0);
66

77
function conectar(){
8-
$link = new mysqli('localhost', 'user', 'password','db');
9-
if ($link->connect_errno) {
10-
die('No pudo conectarse: ' . $link->connect_error);
11-
}
12-
$link->set_charset('utf8');
13-
return $link;
8+
require_once __DIR__.'/config.php';
9+
$link = new mysqli(
10+
$config['db']['host'],
11+
$config['db']['user'],
12+
$config['db']['pass'],
13+
$config['db']['name']
14+
);
15+
if ($link->connect_errno) {
16+
die('No pudo conectarse: ' . $link->connect_error);
17+
}
18+
$link->set_charset('utf8');
19+
return $link;
1420
}
1521

1622
function conectar2(){
17-
$link = new mysqli('localhost', 'user', 'password','db');
18-
if ($link->connect_errno) {
19-
die('No pudo conectarse: ' . $link->connect_error);
20-
}
21-
//mysql_set_charset('utf8',$link);
22-
return $link;
23+
require_once __DIR__.'/config.php';
24+
$link = new mysqli(
25+
$config['db']['host'],
26+
$config['db']['user'],
27+
$config['db']['pass'],
28+
$config['db']['name']
29+
);
30+
if ($link->connect_errno) {
31+
die('No pudo conectarse: ' . $link->connect_error);
32+
}
33+
//mysql_set_charset('utf8',$link);
34+
return $link;
2335
}
2436

2537

0 commit comments

Comments
 (0)