PDF invoice generated but shows php errors

Hi have updated to the latest version and all seems ok so far but on the generation of PDF when viewing in PDF program it is showing the below php errors on some of the products we have added to an invoie, is there a way to fix this

A PHP Error was encountered
Severity: 8192
Message: nl2br(): Passing null to parameter #1 ($string) of type string is deprecated
Filename: pdf/InvoicePlane - overdue.php
Line Number: 147
- overdue.php
Line: 147
Function: nl2br
File: /home/wbdn/public_html/ap.ppd/application/third_party/MX/Loader.php
Line: 474
Function: include
File: /home/wbdn/public_html/ap.ppd/application/third_party/MX/Loader.php
Line: 425
Function: _ci_load
File: /home/wbdn/public_html/ap.ppd/application/helpers/pdf_helper.php
Line: 102
Function: view
Line: 272
Function: generate_invoice_pdf
File: /home/wbdn/public_html/ap.ppd/index.php
Line: 329
Function: require_once

Open up that file and scroll to line 147
Copy / paste 5 lines above and 5 lines below that line 147 in this thread.

I think you’re getting the error, because you have debug modus turned on?

Hi ive gone to that file and this is the code 5 lines above & below, there is no debug turned on as far as im aware, this error only shows on old invoices when the PDF is generated and you look at the PDF, when new invoices are created with the same product added and generate the PDF it does not show this error on the PDF

    foreach ($items as $item) { ?>
            <td><?php _htmlsc($item->item_name); ?></td>
            <td><?php echo nl2br(htmlsc($item->item_description)); ?></td>
            <td class="text-right">
                <?php echo format_amount($item->item_quantity); ?>
                <?php if ($item->item_product_unit) : ?>
                    <small><?php _htmlsc($item->item_product_unit); ?></small>
1 Like

The error comes, because $item->item_description is empty.
Sending an empty value to nl2br gives this message

right okay yes that makes sense, thank you for your help

ive looked within the database and can see its blank, i can add the information required but there is alot.

I dont know alot about phpadmin but would anyone know of a way to update the item_description with some text but only if item_name matches a certain word or item_id matches certain number ?

1 Like

That’s a difficult one!
Try this first: (it updates the item->description with a space, so that nl2br won’t break), it updates it for all lines, so be careful if you want this and if you’re sure the description isn’t filled anywhere:

update ip_items set item_description = ' '

The other ones are variants on top of above one:

update ip_items set item_description = 'some text lorem ipsum' where name like '%InvoicePlane%'


update ip_items set item_description = 'some text lorem ipsum' where item_id in (1,2,3,4,5)

You can also think of variations on above code.

The %InvoicePlane%, that’s ‘wildcards’ on both ends of ‘InvoicePlane’ you can also place the wildcards on either end.

The item_id in (1,2,3,4,5) can also be:
item_id like ‘1313%’

Think of what you really like, write it out, the update queries will show up after that.

Hi thanks for your help im just looking at which one is best

so when i do a search in ip_invoice_items for “Management Fee” as theses are the ones where the description is missing and showing error on the PDF and only need to update them ones and the search brings back 1252 records.

so i try this code below but the simulate query only brings back 94 records, see attach screen shot of the database tables as can see the item_description is NULL

“update ip_invoice_items set item_description = ‘Management Fee’ where item_product_id in (14)”

1 Like

Ok, when i update something, i always want to make a select first, just to see what i’m updating.

Compare these 2, see which one you like:

select item_product_id, item_name, item_description from ip_invoice_items where item_product_id in (14)

With above select you can select product_id 14,15,16 you name it. Great option!

select item_product_id, item_name, item_description from ip_invoice_items where item_name = ‘Management Fee’

From your question I think you want above query, but it’s less precise. If you gave another item besides product_id 14 in the table the name ‘Management Fee’ that will get that description as well.

If product_name is ‘Management Fee’ I want my description to be ‘Management Fee’, then your update statement would be:

update ip_invoice_items set item_description = ‘Management Fee’ where item_name='Management Fee'

Make your select first, just as a precaution

simulate works and can confirm it shows the correct ones, when trying to command you mention to execute it comes back with

" You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Fee’ where item_name=‘Management Fee’’ at line 1"

Paste the SQL query that gave that error, there is something wrong near ‘Fee’, but that occurs two times in that SQL query, so i need to see it.

Hi it was the command above you mention in summary

update ip_invoice_items set item_description = ‘Management Fee’ where item_name='Management Fee'

i was looking at it wrong, teach me to not look when tired, think managed to get the specific ones now updated using below code

update `ip_invoice_items` set `item_description` = 'Management Fee' where `ip_invoice_items`.`item_product_id` = 14;
1 Like

There is a difference between " ` " and " ’ ", if that makes sense.
The " ` " you put around the fields, for example


The " ’ " you put around some values you select, the result of a “where”.

I don’t know if the query i quoted worked for you, maybe phpmyadmin is smart enough