}
// error_reporting==0 when messages are set off with @
- if ($errno & error_reporting())
- $messages[] = array($errno, $errstr, $file, $line);
+ if ($errno & error_reporting()) {
+ $messages[] = array($errno, $errstr, $file, $line);
+ }
else if($errno&~E_NOTICE) { // log all not displayed messages
$user = @$_SESSION["wa_current_user"]->loginname;
$context = isset($SysPrefs) && !$SysPrefs->db_ok ? '[before upgrade]' : '';
$cur_prefix = $db_connections[$_SESSION["wa_current_user"]->cur_con]['tbpref'];
$str .= "sql that failed was : ".str_replace(TB_PREF, $cur_prefix, $sql_statement)."<br>";
- if ($go_debug > 1) display_backtrace();
+// if ($go_debug > 1) display_backtrace();
}
$str .= "<br><br>";
***********************************************************************/
function display_error($msg, $center=true)
{
- trigger_error($msg, E_USER_ERROR);
+ global $go_debug;
+
+ $bt = $go_debug>1 ? ('<hr>'.get_backtrace(true)) : '';
+ trigger_error($msg.$bt, E_USER_ERROR);
}
function display_notification($msg, $center=true)
{
if ($stock_id != "")
{
- $result = db_query("SELECT description, units FROM ".TB_PREF."stock_master WHERE stock_id='$stock_id'");
+ $result = db_query("SELECT description, units FROM ".TB_PREF."stock_master WHERE stock_id=".db_escape($stock_id));
$myrow = db_fetch_row($result);
display_heading("$stock_id - $myrow[0]");
}
function display_backtrace($cond=true, $msg='') {
-
if ($cond) {
if ($msg)
$str = "<center><span class='headingtext'>$msg</span></center>\n";
else
$str = '';
- $str .= '<table border=0>';
- $trace = debug_backtrace();
- foreach($trace as $trn => $tr) {
- if (!$trn) continue;
- $str .= '<tr><td>';
- $str .= $tr['file'].':'.$tr['line'].': ';
- $str .= '</td><td>';
- if (isset($tr['type'])) {
- if($tr['type'] == '::') {
- $str .= $tr['class'].'::';
- } else if($tr['type'] == '->') {
- $str .= '('.$tr['class'].' Object)'.'->';
- }
- }
- foreach($tr['args'] as $n=>$a) {
- if (is_object($tr['args'][$n]))
- $tr['args'][$n] = "(".get_class($tr['args'][$n])." Object)";
- if (is_array($tr['args'][$n]))
- $tr['args'][$n] = "(Array[".count($tr['args'][$n])."])";
- else
- $tr['args'][$n] = "'".$tr['args'][$n]."'";
+ $str .= get_backtrace(true);
+ display_error($str);
+ }
+}
+
+function get_backtrace($html = false)
+{
+ $str = '';
+ if ($html) $str .= '<table border=0>';
+ $trace = debug_backtrace();
+
+ foreach($trace as $trn => $tr) {
+ if (!$trn) continue;
+ if ($html) $str .= '<tr><td>';
+ $str .= $tr['file'].':'.$tr['line'].': ';
+ if ($html) $str .= '</td><td>';
+ if (isset($tr['type'])) {
+ if($tr['type'] == '::') {
+ $str .= $tr['class'].'::';
+ } else if($tr['type'] == '->') {
+ $str .= '('.$tr['class'].' Object)'.'->';
}
- $str .= $tr['function'].'('. implode(',',$tr['args']).')</td>';
+ }
- $str .= '</tr>';
+ foreach($tr['args'] as $n=>$a) {
+ if (is_object($tr['args'][$n]))
+ $tr['args'][$n] = "(".get_class($tr['args'][$n])." Object)";
+ if (is_array($tr['args'][$n]))
+ $tr['args'][$n] = "(Array[".count($tr['args'][$n])."])";
+ else
+ $tr['args'][$n] = "'".$tr['args'][$n]."'";
}
-
- $str .= '</table>';
- display_error($str);
+ $str .= $tr['function'].'('. implode(',',$tr['args']).')</td>';
}
-}
+ if ($html) $str .= '</tr></table>';
+ return $str;
+}
?>
\ No newline at end of file