KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

PHP error in koolreport/core/src/core/Utility.php on line 147 #1226

Open Jim Adamek opened this topic on on Dec 23, 2019 - 4 comments

Jim Adamek commented on Dec 23, 2019

My php error log is full with this error message:

PHP Warning: number_format() expects parameter 1 to be double, string given in /koolreport/core/src/core/Utility.php on line 147

This is occuring where I have numbers formatted according to specs in examples and docs in DataGrid layouts.

Thanks for looking at this...

KoolReport commented on Dec 23, 2019

Could you please provide some of your code related to datagrid and let me know which column cause issue.

Jim Adamek commented on Dec 26, 2019

This is from my view page, pulled out the php portions.

    use \koolreport\datagrid\DataTables;

    DataTables::create(array(
        "dataSource"=>$this->dataStore("UserDB"),
        "themeBase"=>"bs3", // Bootsrap 3 or 4
        "cssClass"=>array(
            "table"=>"table table-striped table-bordered",
            "td"=>"size14"
        ),
        "options"=>array(
            "searching"=>true,
            "paging"=>true,
            "fixedHeader"=>true,
            "select"=>true,
            "order"=>array(
                array(3,"asc") //Sort by last_name asc
            ),
        ),
        "columns"=>array(
            "ID"=>array(
                "type"=>"number",
                "thousandSeparator"=>"",
            ),
            "locale"=>array(
                "type"=>"number",
                "thousandSeparator"=>"",
            ),
            "first_name"=>array(
                "type"=>"string",
            ),
            "last_name"=>array(
                "type"=>"string",
            ),
            "company"=>array(
                "type"=>"string",
            ),
            "acct_name"=>array(
                "type"=>"string",
            ),
            "emailAddress"=>array(
                "type"=>"string",
            ),
            "phone"=>array(
                "type"=>"string",
            ),
            "mobile"=>array(
                "type"=>"string",
            ),
            "package_price"=>array(
                "type"=>"number",
                "prefix"=>"$",
                "decimals"=>2,
                "thousandSeparator"=>",",
                "label"=>"pkg_price",
            ),
            "creation_date"=>array(
                "type"=>"string",
            ),
            "neg_price"=>array(
                "type"=>"number",
                "prefix"=>"$",
                "decimals"=>2,
                "thousandSeparator"=>",",
            ),
            "payment_auth"=>array(
                "type"=>"number",
                "thousandSeparator"=>"",
            ),
        ),

    ));
KoolReport commented on Dec 27, 2019

Could you please check data in two columns neg_price and package_price, there would be data which is not in number format but in string and can not be converted to number. Could you please post us the full error message.

Jim Adamek commented on Dec 27, 2019

As soon as I read your note, then looked at the error message again, I opened up the table structure and sure enough, the neg_price is a string. I assumed it was a number based on my field description. I changed to a string, tested the form again, and the error messages are gone. Thank you for pointing me in the right direction.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

DataGrid