[Solved] Adding custom fields to the Client details page

I’ve added two cutom fields to the Clients database, namely “Client Contact” and “Contact Position”. I would like to put these fields on the Client details page (modules/clients/view.php). I have successfully put the first custom field in with the fillowing code:

<p><b><?php echo $client->client_custom_client_contact; ?></b></p>

but when I put in the second field using the same format as follows:

<p><b><?php echo $client->client_custom_client_contact; ?></b></p>

I get an error message on my front end that says:

A PHP Error was encountered
Severity: Notice

Message: Undefined property: stdClass::$client_custom_client_contact_position

Filename: views/view.php

Line Number: 84

What else do I need to add? I am not a programmer so any help is appreciated! I will need to add the same custom fields to the invoice view. Thanks!!

You will get this error if this field is empty. You should surround this with an if statement.

The “Contact Position” field wasn’t empty but I still got the error.

I have also tried modifying the code to wrap it in an if statement as follows:

<?php if ($invoice->client_contact_client_position) { ?>
                        <span><?php echo $invoice->client_contact client_position; ?></span><br>
                    <?php } ?>

Is my syntax wrong?

No it should be client_custom_client_position:

<?php if ($invoice->client_custom_client_position) { ?>
<span><?php echo $invoice->client_custom_client_position; ?></span><br>
<?php } ?>

oops!! thanks for the correction!!

Is the fix I posted working?

yes it is, thank you!!