forked from iceman101184/ajaxcrud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreheader.php
More file actions
118 lines (98 loc) · 2.99 KB
/
preheader.php
File metadata and controls
118 lines (98 loc) · 2.99 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/* you SHOULD edit the database details below; fill in your database info */
#this is the info for your database connection
####################################################################################
##
$MYSQL_HOST = "localhost";
$MYSQL_LOGIN = "root";
$MYSQL_PASS = "";
$MYSQL_DB = "ajaxcrud_demos";
##
####################################################################################
/********* THERE SHOULD BE NO NEED TO EDIT BELOW THIS LINE *******/
####################################################################################
#a session variable is set by class for much of the CRUD functionality -- eg adding a row
session_start();
#for pesky IIS configurations without silly notifications turned off
error_reporting(E_ALL - E_NOTICE);
$db = @mysql_connect($MYSQL_HOST,$MYSQL_LOGIN,$MYSQL_PASS);
if(!$db){
echo('Unable to authenticate user. <br />Error: <b>' . mysql_error() . "</b>");
exit;
}
$connect = @mysql_select_db($MYSQL_DB);
if (!$connect){
echo('Unable to connect to db <br />Error: <b>' . mysql_error() . "</b>");
exit;
}
mysql_query("SET NAMES 'utf8'");
//mysql_query("SET character_set_results = 'utf8_general_ci', character_set_client = 'utf8_general_ci', character_set_connection = 'utf8_general_ci', character_set_database = 'utf8_general_ci', character_set_server = 'utf8_general_ci'", $db);
# what follows are custom database handling functions - required for the ajaxCRUD class
# ...but these also may be helpful in your application(s) :-)
if (!function_exists('q')) {
function q($q, $debug = 0){
$r = mysql_query($q);
if(mysql_error()){
echo mysql_error();
echo "$q<br>";
}
if($debug == 1)
echo "<br>$q<br>";
if(stristr(substr($q,0,8),"delete") || stristr(substr($q,0,8),"insert") || stristr(substr($q,0,8),"update")){
if(mysql_affected_rows() > 0)
return true;
else
return false;
}
if(mysql_num_rows($r) > 1){
while($row = mysql_fetch_array($r)){
$results[] = $row;
}
}
else if(mysql_num_rows($r) == 1){
$results = array();
$results[] = mysql_fetch_array($r);
}
else
$results = array();
return $results;
}
}
if (!function_exists('q1')) {
function q1($q, $debug = 0){
$r = mysql_query($q);
if(mysql_error()){
echo mysql_error();
echo "<br>$q<br>";
}
if($debug == 1)
echo "<br>$q<br>";
$row = @mysql_fetch_array($r);
if(count($row) == 2)
return $row[0];
else
return $row;
}
}
if (!function_exists('qr')) {
function qr($q, $debug = 0){
$r = mysql_query($q);
if(mysql_error()){
echo mysql_error();
echo "<br>$q<br>";
}
if($debug == 1)
echo "<br>$q<br>";
if(stristr(substr($q,0,8),"delete") || stristr(substr($q,0,8),"insert") || stristr(substr($q,0,8),"update")){
if(mysql_affected_rows() > 0)
return true;
else
return false;
}
$results = array();
$results[] = mysql_fetch_array($r);
$results = $results[0];
return $results;
}
}
?>