-
Notifications
You must be signed in to change notification settings - Fork 0
/
basics.php
47 lines (41 loc) · 1.05 KB
/
basics.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
<?php
//returns a GET-Parameter.
function GET($value, $default = False) {
if (isset($_GET[$value])) {
return $_GET[$value];
} else if ($default == "exit") {
exit();
} else {
return $default;
}
}
//returns a POST-Parameter.
function POST($value, $default = False) {
if (isset($_POST[$value])) {
return $_POST[$value];
} else if ($default == "exit") {
exit();
} else {
return $default;
}
}
//performs a SELECT-Query in MySQL and returns the result.
function SQL($query) {
if ($result = mysql_query($query)) {
$ergebnis = array();
while ($num = mysql_fetch_assoc($result)) {
$ergebnis[] = $num;
}
return $ergebnis;
} else {
error_log("MySQL-Error at: '" . $query . "', error: '" . mysql_error() . "'");
return False;
}
}
//connect to mysql database
include("../generic/credentials.php");
$con = mysql_connect($CREDENTIALS["db_server"], $CREDENTIALS["db_username"], $CREDENTIALS["db_password"]) or exit(mysql_error());
mysql_select_db($CREDENTIALS["db_db"], $con) or exit(mysql_error());
mysql_set_charset('utf8');
session_start();
?>