-function SQL_QUERY($sql_string, $F, $L) {
- global $link, $CSS, $_CONFIG, $OK;
+function SQL_QUERY ($sqlString, $F, $L, $enableCodes = TRUE) {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__][$sqlString])) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called: ' . $sqlString);
+
+ // Trim SQL string
+ $sqlStringModified = trim($sqlString);
+
+ // Empty query string or link is not up?
+ if (empty($sqlStringModified)) {
+ // Empty SQL string!
+ reportBug(__FUNCTION__, __LINE__, sprintf("SQL string is empty, please fix this: file=%s, line=%s",
+ basename($F),
+ $L
+ ));
+ } elseif (!SQL_IS_LINK_UP()) {
+ // We should not quietly ignore this
+ reportBug(__FUNCTION__, __LINE__, sprintf("Cannot query database: sqlString=%s,file=%s,line=%s",
+ $sqlStringModified,
+ basename($F),
+ $L
+ ));
+ }
+
+ // Remove \t, \n and \r from queries they may confuse some MySQL versions
+ $sqlStringModified = str_replace(array(chr(9), PHP_EOL, chr(13)), array(' ', ' ', ' '), $sqlStringModified);
+
+ // Compile config entries out
+ $sqlStringModified = SQL_PREPARE_SQL_STRING($sqlStringModified, $enableCodes);