douxi4287 2012-07-18 09:46
浏览 38
已采纳

标识调用函数的行

Having a repetitive code like so:

$SQL = " INSERT INTO ... ";

mysql_query($SQL, $conexion);
$error = mysql_error();

if($_ADM['id_user']==1) {
    if( ! empty($error)) {
        $debug = array(
                    'message' => "SQL Error in news_edit module.",
                    'line'    => '177',
                    'error'   => $error,
                    'SQL'     => $SQL
                );
        exit(print_r($debug));
    }
}

This is a common code, that repeats its self every time $SQL changes. What I'm trying to achieve is a way to debug if any error occurs and as I you can see, I have the line parameter which contains the number line where last mysql_query was executed, but I have to type that manually and every time I add code before it, the line parameters needs to be changed with the new line value.

Is there any way of identifying where was last time mysql_query executed? Any other way of improving the code above?

  • 写回答

2条回答 默认 最新

  • doudun2212 2012-07-18 09:49
    关注

    I think what you want is debug_backtrace function. Check the manual for specs:

    http://php.net/manual/en/function.debug-backtrace.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度