Prevent multiple ifelse statements in php
Try something like this

&lt;?php

function buildErrorMessage($message, $row = null, $header = null, $fieldValue = null) {

    if ($row) {
        $message .=  ": row {$row}";
    }

    if ($header) {
        $message .=  ", header {$header}";
    }

    if ($fieldValue) {
        $message .=  ", value \"{$fieldValue}\"";
    }

    return $message;
}

// Tests
echo buildErrorMessage('one');
echo buildErrorMessage('two', 2);
echo buildErrorMessage('three', 3, 'header');
echo buildErrorMessage('four', 4, 'header', 'value');
echo buildErrorMessage('five', null, null, 'value');