SQL_IS_LINK_UP() aborts if wether no resource or null is given
[mailer.git] / inc / db / lib-mysql3.php
index 4492111863fba94c9f3d3f29edc9763e75de89ff..10372a4a3b45e759e37384798d5302e10eac3ce3 100644 (file)
@@ -39,8 +39,6 @@ if (!defined('__SECURITY')) {
 
 // SQL queries
 function SQL_QUERY ($sql_string, $F, $L) {
-       global $OK;
-
        // Link is up?
        if (!SQL_IS_LINK_UP()) return false;
 
@@ -80,10 +78,10 @@ Query string:<br />
                // Debugging stuff...
                //
                $fp = fopen(constant('PATH')."inc/cache/mysql.log", 'a') or mxchange_die("Cannot write mysql.log!");
-               if (!isset($OK)) {
+               if (!isset($GLOBALS['sql_first_entry'])) {
                        // Write first entry
                        fwrite($fp, "Module=".$GLOBALS['module']."\n");
-                       $OK = true;
+                       $GLOBALS['sql_first_entry'] = true;
                } // END - if
                fwrite($fp, $F."(LINE=".$L."|NUM=".SQL_NUMROWS($result)."|AFFECTED=".SQL_AFFECTEDROWS()."|QUERYTIME:".$queryTime."): ".str_replace('\r', "", str_replace('\n', " ", $sql_string))."\n");
                fclose($fp);
@@ -387,6 +385,12 @@ function SQL_GET_LINK () {
 
 // Setter for link
 function SQL_SET_LINK ($link) {
+       // Is this a resource or null?
+       if ((!is_resource($link)) && (!is_null($link))) {
+               // This should never happen!
+               trigger_error(sprintf("link is not resource or null. Type: %s", gettype($link)));
+       } // END - if
+
        // Set it
        $GLOABLS['sql_link'] = $link;
 }