Import PHP Error?


#1

Hey All,

I’m just setting up InvoicePlane and whilst it looks great and seems to work well I can’t get the importer to work, I’m getting errors:

A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: models/Mdl_import.php

Line Number: 388

Backtrace:

File: /var/sites/i/MYSITE/public_html/application/modules/import/models/Mdl_import.php
Line: 388
Function: _error_handler

File: /var/sites/i/MYSITE/public_html/application/modules/import/controllers/Import.php
Line: 82
Function: record_import_details

File: /var/sites/i/MYSITE/public_html/index.php
Line: 325
Function: require_once
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /var/sites/i/MYSITE/public_html/vendor/codeigniter/framework/system/core/Exceptions.php:271)

Filename: helpers/url_helper.php

Line Number: 564

Backtrace:

File: /var/sites/i/MYSITE/public_html/application/modules/import/controllers/Import.php
Line: 105
Function: redirect

File: /var/sites/i/MYSITE/public_html/index.php
Line: 325
Function: require_once

If anyone can help or know where I’m going wrong that would be amazing!


#2

That’s because you have a client import file that did not have any valid data.


#3

I’ve made a sample CSV with a single line of data and it still fails?


#4

Ensure your file has a header, and that the fields are all correct.

The import function in application/modules/import/models/Mdl_import.php is designed to return a list of new id that were created as part of the import. It is returning an empty list, therefore your error.

I would also suggest you turn on debugging in the ip_config.php file to see if there is anything logged as to why your data was not inserted into the database.


#5

Here is my CSV: http://mlny.in/d10c7cd5c7cc (just a demo)

Error logging is on and only showing a 200 response.

Is something wrong with my csv?


#6

As I stated above, the issue appears to be with your clents.csv file, not your payments.csv.

If you follow the error messages, it complains at line 82 of the controller, which is in the following code.

            if ($file == 'clients.csv') {
                $ids = $this->mdl_import->import_data($file, 'ip_clients');

                $this->mdl_import->record_import_details($import_id, 'ip_clients', 'clients', $ids);
            } 

So you should check your clients.csv file first.


#7

@paulmaloney how did you create your clients.csv? offer it for download as well please.
Sometimes, when you create your csv file from Excel for example, the import will not work.

First thing to do in that controller is to print_r($ids) to make sure that you got some ids from the import.


#8

I gave up on it. I switched to Wave and it ticks all the boxes I need. Not self hosted but just one of those things.