MySQL error trapped in SQL library:

"; if ($locked_tables == 'locked') { SQL_Query("UNLOCK TABLES;"); } exit; } function SQL_query ($a_query) { global $default_db, $sql_error; CheckConnection(); $res = @ mysql_query ($a_query, $default_db); if (!$res) { ErrorHandler($a_query); } return $res; } function SQL_fetch_object ($rs) { $res = @ mysql_fetch_object ($rs, MYSQL_ASSOC); if (!$res) { ErrorHandler("mysql_fetch_object from $rs"); } return $res; } function SQL_fetch_array ($rs, $type = MYSQL_ASSOC) { global $default_db; CheckConnection(); $row = @ mysql_fetch_array($rs, $type); if (mysql_errno($default_db) != 0) { ErrorHandler("mysql_fetch_array from $rs"); } return $row; } function SQL_fetch_row ($rs) { global $default_db; CheckConnection(); $row = @ mysql_fetch_row($rs); if (mysql_errno($default_db) != 0) { ErrorHandler("mysql_fetch_row from $rs"); } return $row; } function SQL_free_result ($rs) { $res = @ mysql_free_result ($rs); if (!$res) { ErrorHandler("mysql_free_result of $rs"); } return $res; } function SQL_close () { global $default_db; CheckConnection(); $res = @ mysql_close ($default_db); if (!$res) { ErrorHandler("mysql_close of $default_db"); } return $res; } function SQL_DateToStr ($a_time) { return $a_time; } function SQL_DateToSQLStr ($date_string) { $time_stamp = StrToTime($date_string); if ($time_stamp == -1 || !$date_string) { return "NULL"; } return "'".Date("Y-m-d", $time_stamp)."'"; } function SQL_DateTimeToSQLStr ($dt_string) { $time_stamp = StrToTime($dt_string); if ($time_stamp == -1 || !$dt_string) { return "NULL"; } return "'".Date("Y-m-d H:i:s", $time_stamp)."'"; } function SQL_NumberToSQLStr ($number) { if (!is_numeric($number)) { return "NULL"; } else { return $number; } } function SQL_StringToSQLStr ($string) { if (empty($string)) { return "NULL"; } else { return "'".$string."'"; } } /* Assumes the query returns one row result with one field in it only and returns it as a string */ function SQL_GetFieldValue ($sql_qry) { global $default_db; CheckConnection(); $query_res = SQL_query ($sql_qry); $data_row = SQL_fetch_row($query_res); if ($data_row) { $result = $data_row[0]; } else { unset($result); } SQL_free_result ($query_res); return $result; } /* Assumes the query returns one row result and returns it as an associative array */ function SQL_GetQueryResult ($sql_qry) { $query_res = SQL_query ($sql_qry); $data_row = SQL_fetch_array ($query_res); SQL_free_result ($query_res); return $data_row; } function SQL_GetQueryResults ($sql_qry, $array_type = MYSQL_ASSOC) { $result_array = Array(); $result_count = 0; $data_set = SQL_query ($sql_qry); while ($data_row = SQL_fetch_array ($data_set, $array_type)) { $result_array[$result_count] = $data_row; $result_count++; } SQL_free_result ($data_set); return $result_array; } function SQL_GetOneColumnResults ($sql_qry) { $result_array = Array(); $result_count = 0; $data_set = SQL_query ($sql_qry); while ($data_row = SQL_fetch_row ($data_set)) { $result_array[$result_count] = $data_row[0]; $result_count++; } SQL_free_result ($data_set); return $result_array; } function OrigUser2DB($str) // Converts apostrof for storing to InterBase DB { $str = ereg_replace("\\\'", "''", $str); return($str); } function SQL_QueryEscape($string) //tries to escape ", ', \ (double quotes, quotes and backslash) when using this string in // MySQL query { return addslashes($string); } function SQL_QueryUnEscape(&$string) //invert function { $string = stripslashes($string); return $string; } function SQL_Disconnect() { mysql_close(); } function SQL_InsertId() { return MySQL_Insert_Id(); } function ConvertStringToNULL($my_string) { if ($my_string=="") return "NULL"; else return "'$my_string'"; } function SQL_GetFieldValuesInArray($sql_qry) { $results = SQL_GetQueryResults($sql_qry, MYSQL_NUM); $ret_arr = Array(); reset($results); while($result = array_shift($results)) { array_push($ret_arr, $result[0]); } return $ret_arr; } //this function is for backward compatibility of the name function SQL_GetQueryResultsInArray($sql_qry) { return SQL_GetFieldValuesInArray($sql_qry); } ?>", ">", $str); return($str); } function RemoveDiakritic($str) { $str = strtr($str, "abcdefghijklmnopqrstuvwxyzڊ", "ABCDEFGHIJKLMNOPQRSTUVWXYZRAALCEEIDNOORUUSTZLYARAALCEEIDNOORUUSTZLYA"); return($str); } function ConvertString($str) // Converts apostrof for storing to DB { if ($str == '') return "''"; Else { //$str = ereg_replace("\\\'", "''" , $str); //$str = ereg_replace('\\\"', "''", $str); $str= ereg_replace("([^\])'", "\\1\'", $str); $str= ereg_replace("^'", "\\'", $str); return("'" . $str . "'"); } } function ConvertToNULL($val) // Converts to NULL { if (($val == '')||(!is_numeric($val))) return "NULL"; else return $val; } function isDate ($year, $month, $day) { if (($year <1) OR ($month<1) OR ($month>12) OR ($day<1) OR ($day>31)) return false; else return true; } function DateToDisplayStr ($a_time) { if (Trim($a_time) == '') { return ''; } $yyyy = StrTok ($a_time, '-'); $mm = StrTok ('-'); $dd = StrTok ('-'); $dd = StrTok ($dd, ' '); If (!isDate(IntVal($yyyy),IntVal($mm),IntVal($dd))) { return ''; } $displayed_datum=$dd .".".$mm.".".$yyyy; return $displayed_datum; } function GetOurDateTime ($a_time) { if (Trim($a_time) == '') { return ''; } $yyyy = StrTok ($a_time, '-'); $mm = StrTok ('-'); $ddt = StrTok ('-'); $dd = StrTok ($ddt, ' '); $tt=StrTok (' '); If (!isDate(IntVal($yyyy),IntVal($mm),IntVal($dd))) { return ''; } $displayed_datum=$dd .".".$mm.".".$yyyy . " " . $tt; return $displayed_datum; } function DisplayDateToStr ($displayed_datum) { if (Trim($displayed_datum) == '') return ''; List($dd,$mm,$yyyy) = Explode(".",$displayed_datum); If (!isDate(IntVal($yyyy),IntVal($mm),IntVal($dd))) return ''; $a_time=$yyyy."-".$mm."-".$dd; return $a_time; } function DateStrForInterbase ($displayed_datum) { if (Trim($displayed_datum) == '') return ''; List($dd,$mm,$yyyy) = Explode(".",$displayed_datum); If (!isDate(IntVal($yyyy),IntVal($mm),IntVal($dd))) return ''; $a_time=$yyyy."-".$mm."-".$dd; return $a_time; } function QuoteFieldTags ($tag_list) { $quoted_list = ""; $tag = Trim(StrTok ($tag_list, ',')); while ($tag) { if ($quoted_list) { $quoted_list .= ','; } $quoted_list .= "'$tag'"; $tag = Trim(StrTok (',')); } return $quoted_list; } Function CreateSelectHTML ($select_name, $result_array, $id_field, $display_field, $select_value, $empty_option, $on_change) { // creates HTML code for SELECT box using given values $html = "\n"; return $html; } Function CreateOptionsHTML ($result_array, $id_field, $display_field, $select_value) { // creates HTML code for OPTIONS in SELECT box using given values $html = ""; for ($i=0;$i\n"; } return $html; } Function DisplayInputField($name, $value, $size, $maxlength) { // displays input field //echo ""; echo ""; //echo "\n"; return; } Function DisplayHiddenField($name, $value) { echo ""; return; } Function DisplayPasswordField($name, $value, $size, $maxlength) { // displays input field echo ""; echo ""; echo "\n"; return; } Function DisplayTextField($name, $value, $size, $rows) { // displays input field echo "\n"; return; } Function DisplayUploadField($name, $value, $size, $maxlength) { // displays input field echo ""; return; } Function DisplayCheckboxField($name, $value='', $checked=false, $onclick='') { // displays input field $html = ""; echo ""; echo ""; echo ""; return; } function DisplayDateSelectBoxes($name_prefix, $datum = '') { if ($datum) { $rok = StrTok ($datum, '-'); $mesiac = StrTok ('-'); $den = StrTok ('-'); } else { $rok = Date("Y"); } $html .= " \n"; if ((TRIM($empty_option) == "YES") OR (TRIM($empty_option) == "ALL")) { $html .= "\n"; } $html .= "\n"; $html .= "