-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconnect.inc.php
67 lines (61 loc) · 1.64 KB
/
connect.inc.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
57
58
59
60
61
62
63
64
65
66
67
<?
// new version will be db.inc.php
// but is still in development :(
require_once('cfg/_cfg.php');
require_once('cfg/_tables.php');
$db_conn = null;
function db_Connect ($silent = false)
{
global $g_dbserver,$g_dbuser,$g_dbpass,$g_dbname,$g_dbport,$g_baseadr, $db_conn;
$spojeni = new mysqli($g_dbserver,$g_dbuser,$g_dbpass, '', $g_dbport);
if (!$spojeni)
{
if($silent)
return false;
else
{
header("location: ".$g_baseadr."error.php?code=11");
exit;
}
}
$spojeni->select_db ($g_dbname);
$spojeni->query("SET CHARACTER SET UTF8");
$db_conn = $spojeni;
return true;
}
// from db.inc.php
function correct_sql_string($str)
{
global $db_conn;
return mysqli_real_escape_string($db_conn, $str);
}
///////////////////////////////////////////////////////////////////////////////
$db_query_cnt = 0;
function query_db($sql_query)
{
global $db_query_cnt, $db_conn, $g_is_release;
if (!$g_is_release) {
echo "<code>$sql_query |||| pocet ovlivnenych radku : ".$db_conn->affected_rows."</code><br/>";
/**
* //log to console
* // $console_message = "sql query: ".$sql_query." || pocet ovlivnenych radku :".$db_conn->affected_rows;
* // echo '<script>console.log("'.$console_message.'")</script>';
*/
}
$db_query_cnt++;
try
{
$result=$db_conn->query($sql_query);
}
catch (mysqli_sql_exception $ex)
{
$msg = 'Popis: '.$ex->getMessage();
echo ('Chyba při provádění dotazu do databáze. '.$msg."<br />\n");
LogToFile(dirname(__FILE__) . '/logs/.db_errors.txt','Db query error - '.$msg.__FILE__);
$result = false;
}
//dokud nebude pripraven db.inc.php nebo sem nepridame funkci error_db()
// or error_db();
return $result;
}
?>