| ... | ... |
@@ -9,6 +9,7 @@ function dbconnect($dbhost, $dbuser, $dbpass, $dbname ) {
|
| 9 | 9 |
include(_BASEDIR."languages/en.php"); // Because we haven't got a language set yet. |
| 10 | 10 |
die(_FATALERROR." "._NOTCONNECTED); |
| 11 | 11 |
} |
| 12 |
+ mysqli_query($mysql_access, "SET SESSION sql_mode = 'MYSQL40'"); |
|
| 12 | 13 |
return $mysql_access; |
| 13 | 14 |
} |
| 14 | 15 |
|
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,67 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+// Some DB functions |
|
| 4 |
+if(!function_exists("dbconnect")) { // just in case. Some people seemed to be having an issue and this was the easiest fix.
|
|
| 5 |
+ |
|
| 6 |
+function dbconnect($dbhost, $dbuser, $dbpass, $dbname ) {
|
|
| 7 |
+ $mysql_access = new mysqli($dbhost, $dbuser, $dbpass, $dbname); |
|
| 8 |
+ if(mysqli_connect_error()) {
|
|
| 9 |
+ include(_BASEDIR."languages/en.php"); // Because we haven't got a language set yet. |
|
| 10 |
+ die(_FATALERROR." "._NOTCONNECTED); |
|
| 11 |
+ } |
|
| 12 |
+ return $mysql_access; |
|
| 13 |
+} |
|
| 14 |
+ |
|
| 15 |
+ |
|
| 16 |
+function dbquery($query) {
|
|
| 17 |
+ global $debug, $headerSent, $dbconnect; |
|
| 18 |
+ if($debug && $headerSent) echo "<!-- $query -->\n"; |
|
| 19 |
+ $result = $dbconnect->query($query) or accessDenied( _FATALERROR.(isADMIN ? "Query: ".$query."<br />Error: (".$dbconnect->mysqli_errno.") ".$dbconnect->mysqli_error : ""));
|
|
| 20 |
+ return $result; |
|
| 21 |
+} |
|
| 22 |
+ |
|
| 23 |
+function dbnumrows($query) {
|
|
| 24 |
+ global $debug, $dbconnect; |
|
| 25 |
+ if ($query === false && $debug) {
|
|
| 26 |
+ echo "<!-- dbnumrows ".$dbconnect->mysqli_error." -->\n"; |
|
| 27 |
+ } |
|
| 28 |
+ return $query->num_rows; |
|
| 29 |
+} |
|
| 30 |
+ |
|
| 31 |
+function dbassoc($query) {
|
|
| 32 |
+ global $debug, $dbconnect; |
|
| 33 |
+ if ($query === false && $debug) {
|
|
| 34 |
+ echo "<!-- dbassoc ".$dbconnect->mysqli_error." -->\n"; |
|
| 35 |
+ } |
|
| 36 |
+ return $query->fetch_assoc(); |
|
| 37 |
+} |
|
| 38 |
+ |
|
| 39 |
+function dbinsertid($tablename = 0) {
|
|
| 40 |
+ global $dbconnect; |
|
| 41 |
+ return $dbconnect->insert_id; |
|
| 42 |
+} |
|
| 43 |
+ |
|
| 44 |
+function dbrow($query) {
|
|
| 45 |
+ global $debug, $dbconnect; |
|
| 46 |
+ if ($query === false && $debug) {
|
|
| 47 |
+ if($error) echo "<!-- dbrow ".$dbconnect->mysqli_error." -->\n"; |
|
| 48 |
+ } |
|
| 49 |
+ return $query->fetch_row(); |
|
| 50 |
+} |
|
| 51 |
+ |
|
| 52 |
+function dbclose() {
|
|
| 53 |
+ global $dbconnect; |
|
| 54 |
+ $dbconnect->close(); |
|
| 55 |
+} |
|
| 56 |
+ |
|
| 57 |
+// Used to escape text being put into the database. |
|
| 58 |
+function escapestring($str) {
|
|
| 59 |
+ global $dbconnect; |
|
| 60 |
+ if (!is_array($str)) return $dbconnect->real_escape_string($str); |
|
| 61 |
+ return array_map('escapestring', $str);
|
|
| 62 |
+} |
|
| 63 |
+ |
|
| 64 |
+// End DB functions |
|
| 65 |
+ |
|
| 66 |
+} |
|
| 67 |
+?> |
|
| 0 | 68 |
\ No newline at end of file |