// Run SQL command
//* DEBUG: */ echo $sql_string."<br />\n";
$result = mysql_query($sql_string, SQL_GET_LINK())
- or addFatalMessage($F." (".$L."):".mysql_error()."<br />
+ or addFatalMessage(__FUNCTION__, __LINE__, $F." (".$L."):".mysql_error()."<br />
Query string:<br />
".$sql_string);
// SQL connect
function SQL_CONNECT ($host, $login, $password, $F, $L) {
// Try to connect
- $connect = mysql_connect($host, $login, $password) or addFatalMessage($F." (".$L."):".mysql_error());
+ $connect = mysql_connect($host, $login, $password) or addFatalMessage(__FUNCTION__, __LINE__, $F." (".$L."):".mysql_error());
// Set the link resource
SQL_SET_LINK($connect);
if (!SQL_IS_LINK_UP()) return false;
// Return the result
- return mysql_select_db($dbName, SQL_GET_LINK()) or addFatalMessage($F." (".$L."):".mysql_error());
+ return mysql_select_db($dbName, SQL_GET_LINK()) or addFatalMessage(__FUNCTION__, __LINE__, $F." (".$L."):".mysql_error());
}
// SQL close link
} // END - if
// Close database link and forget the link
- $close = mysql_close(SQL_GET_LINK()) or addFatalMessage($F." (".$L."):".mysql_error());
+ $close = mysql_close(SQL_GET_LINK()) or addFatalMessage(__FUNCTION__, __LINE__, $F." (".$L."):".mysql_error());
// Close link
SQL_SET_LINK(null);
}
// Escape a string for the database
-function SQL_ESCAPE ($str, $secureString=true,$strip=true) {
+function SQL_ESCAPE ($str, $secureString=true, $strip=true) {
// Secure string first? (which is the default behaviour!)
if ($secureString) {
// Then do it here
// 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;
+ $GLOBALS['sql_link'] = $link;
}
// Checks if the link is up