Database links should be up before we send queries, now a trigger_error() is added...
[mailer.git] / inc / db / lib-mysql3.php
index 8f57bf199e99bf1edbd2716f7d0f4065172253da..e005e753b95a7fe87ade5427feda0898a19e913f 100644 (file)
@@ -45,7 +45,17 @@ if (!defined('__SECURITY')) {
 // SQL queries
 function SQL_QUERY ($sql_string, $F, $L) {
        // Link is up?
-       if (!SQL_IS_LINK_UP()) return false;
+       if (!SQL_IS_LINK_UP()) {
+               // We should not quietly ignore this!
+               trigger_error(sprintf("Cannot query database: sql_string=%s,file=%s,line=%s",
+                       $sql_string,
+                       basename($F),
+                       $L
+               ));
+
+               // Return 'false' because it has failed
+               return false;
+       } // END - if
 
        // Remove \t, \n and \r from queries they may confuse some MySQL version I have heard
        $sql_string = str_replace("\t", " ", str_replace("\n", " ", str_replace("\r", " ", $sql_string)));
@@ -62,7 +72,7 @@ function SQL_QUERY ($sql_string, $F, $L) {
        // Run SQL command
        //* DEBUG: */ echo $sql_string."<br />\n";
        $result = mysql_query($sql_string, SQL_GET_LINK())
-       or addFatalMessage(__FUNCTION__, __LINE__, $F." (".$L."):".mysql_error()."<br />
+               or addFatalMessage(__FUNCTION__, __LINE__, $F." (".$L."):".mysql_error()."<br />
 Query string:<br />
 ".$sql_string);