| ... | ... |
@@ -18,14 +18,14 @@ function dbconnect($dbhost, $dbuser, $dbpass, $dbname ) {
|
| 18 | 18 |
function dbquery($query) {
|
| 19 | 19 |
global $debug, $headerSent, $dbconnect; |
| 20 | 20 |
if($debug && $headerSent) echo "<!-- $query -->\n"; |
| 21 |
- $result = $dbconnect->query($query) or accessDenied( _FATALERROR.(isADMIN ? "Query: ".$query."<br />Error: (".$dbconnect->mysqli_errno.") ".$dbconnect->mysqli_error : ""));
|
|
| 21 |
+ $result = $dbconnect->query($query) or accessDenied( _FATALERROR.(isADMIN ? "Query: ".$query."<br />Error: (".$dbconnect->errno.") ".$dbconnect->error : ""));
|
|
| 22 | 22 |
return $result; |
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 | 25 |
function dbnumrows($query) {
|
| 26 | 26 |
global $debug, $dbconnect; |
| 27 | 27 |
if ($query === false && $debug) {
|
| 28 |
- echo "<!-- dbnumrows ".$dbconnect->mysqli_error." -->\n"; |
|
| 28 |
+ echo "<!-- dbnumrows ".$dbconnect->error." -->\n"; |
|
| 29 | 29 |
} |
| 30 | 30 |
return $query->num_rows; |
| 31 | 31 |
} |
| ... | ... |
@@ -33,7 +33,7 @@ function dbnumrows($query) {
|
| 33 | 33 |
function dbassoc($query) {
|
| 34 | 34 |
global $debug, $dbconnect; |
| 35 | 35 |
if ($query === false && $debug) {
|
| 36 |
- echo "<!-- dbassoc ".$dbconnect->mysqli_error." -->\n"; |
|
| 36 |
+ echo "<!-- dbassoc ".$dbconnect->errno." -->\n"; |
|
| 37 | 37 |
} |
| 38 | 38 |
return $query->fetch_assoc(); |
| 39 | 39 |
} |
| ... | ... |
@@ -46,7 +46,7 @@ function dbinsertid($tablename = 0) {
|
| 46 | 46 |
function dbrow($query) {
|
| 47 | 47 |
global $debug, $dbconnect; |
| 48 | 48 |
if ($query === false && $debug) {
|
| 49 |
- if($error) echo "<!-- dbrow ".$dbconnect->mysqli_error." -->\n"; |
|
| 49 |
+ if($dbconnect->error) echo "<!-- dbrow ".$dbconnect->errno." -->\n"; |
|
| 50 | 50 |
} |
| 51 | 51 |
return $query->fetch_row(); |
| 52 | 52 |
} |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,69 @@ |
| 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 |
+ mysqli_query($mysql_access, "SET SESSION sql_mode = 'NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION'"); |
|
| 13 |
+ mysqli_query($mysql_access, "SET NAMES UTF8;"); |
|
| 14 |
+ return $mysql_access; |
|
| 15 |
+} |
|
| 16 |
+ |
|
| 17 |
+ |
|
| 18 |
+function dbquery($query) {
|
|
| 19 |
+ global $debug, $headerSent, $dbconnect; |
|
| 20 |
+ if($debug && $headerSent) echo "<!-- $query -->\n"; |
|
| 21 |
+ $result = $dbconnect->query($query) or accessDenied( _FATALERROR.(isADMIN ? "Query: ".$query."<br />Error: (".$dbconnect->mysqli_errno.") ".$dbconnect->mysqli_error : ""));
|
|
| 22 |
+ return $result; |
|
| 23 |
+} |
|
| 24 |
+ |
|
| 25 |
+function dbnumrows($query) {
|
|
| 26 |
+ global $debug, $dbconnect; |
|
| 27 |
+ if ($query === false && $debug) {
|
|
| 28 |
+ echo "<!-- dbnumrows ".$dbconnect->mysqli_error." -->\n"; |
|
| 29 |
+ } |
|
| 30 |
+ return $query->num_rows; |
|
| 31 |
+} |
|
| 32 |
+ |
|
| 33 |
+function dbassoc($query) {
|
|
| 34 |
+ global $debug, $dbconnect; |
|
| 35 |
+ if ($query === false && $debug) {
|
|
| 36 |
+ echo "<!-- dbassoc ".$dbconnect->mysqli_error." -->\n"; |
|
| 37 |
+ } |
|
| 38 |
+ return $query->fetch_assoc(); |
|
| 39 |
+} |
|
| 40 |
+ |
|
| 41 |
+function dbinsertid($tablename = 0) {
|
|
| 42 |
+ global $dbconnect; |
|
| 43 |
+ return $dbconnect->insert_id; |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+function dbrow($query) {
|
|
| 47 |
+ global $debug, $dbconnect; |
|
| 48 |
+ if ($query === false && $debug) {
|
|
| 49 |
+ if($error) echo "<!-- dbrow ".$dbconnect->mysqli_error." -->\n"; |
|
| 50 |
+ } |
|
| 51 |
+ return $query->fetch_row(); |
|
| 52 |
+} |
|
| 53 |
+ |
|
| 54 |
+function dbclose() {
|
|
| 55 |
+ global $dbconnect; |
|
| 56 |
+ $dbconnect->close(); |
|
| 57 |
+} |
|
| 58 |
+ |
|
| 59 |
+// Used to escape text being put into the database. |
|
| 60 |
+function escapestring($str) {
|
|
| 61 |
+ global $dbconnect; |
|
| 62 |
+ if (!is_array($str)) return $dbconnect->real_escape_string($str); |
|
| 63 |
+ return array_map('escapestring', $str);
|
|
| 64 |
+} |
|
| 65 |
+ |
|
| 66 |
+// End DB functions |
|
| 67 |
+ |
|
| 68 |
+} |
|
| 69 |
+?> |
|
| 0 | 70 |
\ No newline at end of file |