duandongjin5647 2013-12-04 17:45
浏览 21
已采纳

致命错误:函数名必须是字符串PHP函数[关闭]

Can anyone help? I am getting the following error: Fatal Error: Function name must be a string in .... on line 120

Here is the code - it looks fine to me, but maybe a second pair of eyes? I will highlight line 120.

function display($name, $display_name, $id, $package_results, $payment_type, $before_percent_box, $before_price_box, $after_percent_box, $after_price_box, $min_price_box)
{
    LINE 120 -> $records = $mysql_num_rows($package_results);   

    if ($records > 0)   //If there are records
    {
        while($package_row = mysql_fetch_assoc($results))
        {

        }
    }
    else    //If there were no records found
    {
        if ($payment_type == 1)     //If it is a PAYG
        {
            createPricePackageTable($name, $display_name, $id, "", $before_percent_box, $before_price_box, $after_percent_box, $after_price_box, $min_price_box, $records, 1);  //Create one blank table, 1 month
        }
        else    //If it is any other payment type other than PAYG
        {
            createPricePackageTable($name, $display_name, $id, "", $before_percent_box, $before_price_box, $after_percent_box, $after_price_box, $min_price_box, $records, 2);  //Create two blank tables, 6 and 12 months 
        }
    }
}

I have also includes the code leading up to the calling of the above function:

function build($name, $id, $memberid, $results) 
{
    echo "<div class='popup-column' style='width: 100%;'>";
        echo "<h3>Payment Option " . $memberid . "</h3>";

        echo "<p>Which payment options do you offer?</p>";

        echo "<div class='payment-options'>";
            $payment_type = 0;

            $display_name = $name;      //Get the name of the Payment Type
            $name = str_replace(" ", "", $name);

            $disable  = 'readonly="readonly" class="readonly"';
            $before_percent_box = '';   //Setup variables to hold whether a input box is disabled or not
            $before_price_box = '';
            $after_percent_box  = '';
            $after_price_box  = '';
            $min_price_box    = '';

            switch($name)   //Disable some input box fields
            {
                case "Split1" :
                    $payment_type = 5;

                    break;

                case "Split2" :
                    $payment_type = 6;

                    break;

                case "Fixed1" :
                    $payment_type = 3;

                    $before_percent_box = $disable;
                    $after_percent_box  = $disable;
                    $after_price_box  = $disable;
                    $min_price_box    = $disable;

                    break;

                case "Fixed2" :
                    $payment_type = 4;

                    $before_percent_box = $disable;
                    $after_percent_box  = $disable;
                    $after_price_box  = $disable;
                    $min_price_box    = $disable;

                    break;

                case "PAYG" :
                    $payment_type = 1;

                    $before_percent_box = $disable;
                    $after_percent_box  = $disable;
                    $after_price_box  = $disable;
                    $min_price_box    = $disable;

                    break;

                case "Commission" :
                    $payment_type = 2;

                    $before_percent_box = $disable;
                    $before_price_box = $disable;

                    break;
            }

            displayPackagePricesTable($name, $display_name, $id, $results, $payment_type, $before_percent_box, $before_price_box, $after_percent_box, $after_price_box, $min_price_box);    //Display the table with the prices

...

  • 写回答

2条回答 默认 最新

  • duan5991518 2013-12-04 17:46
    关注

    Since it is possible to call a variable function, PHP tries to call a function named $mysql_num_rows. That variable isn't defined anywhere in your code and is NULL. So you'll essentially be trying to call a function whose name is not a string and causes PHP to trigger that Fatal error.

    Change that line to:

    $records = mysql_num_rows($package_results);   
              ^-- remove the $
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用MATLAB进行余弦相似度计算加速
  • ¥15 服务器安装php5.6版本
  • ¥15 我想用51单片机和数码管做一个从0开始的计数表 我写了一串代码 但是放到单片机里面数码管只闪烁一下然后熄灭
  • ¥20 系统工程中,状态空间模型中状态方程的应用。请猛男来完整讲一下下面所有问题
  • ¥15 我想在WPF的Model Code中获取ViewModel Code中的一个参数
  • ¥15 arcgis处理土地利用道路 建筑 林地分类
  • ¥20 使用visual studio 工具用C++语音,调用openslsx库读取excel文件的sheet问题
  • ¥100 寻会做云闪付tn转h5支付链接的技术
  • ¥15 DockerSwarm跨节点无法访问问题
  • ¥15 使用dify通过OpenAI 的API keys添加OpenAI模型时报了“Connection Error”错误