Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

reporting errors (No Found Records)

Featured Replies

I have a PHP page that allows users to search our department directory (of people). It works, but if no records are found, then they get a header graphic and nothing else. I have looked online, and I think my FileMaker::IsError syntax is correct, but it does not display. Would someone look at the attached file and see what I've done wrong? (Once I get it to display an error code, I can customize it and trap for various errors, but right now I only get the header!) Thank you, Brian

namesearch.php

There is an example on this page: https://jonathanstark.com/fm/web-publishing-with-filemaker-and-php.php

What you are looking for in this case is the part that gives "No Records Found," but there should really be some sort of $result.count() or similar like in FX.php where there is $result['foundCount'] as foundcount = 0 is not really an error; it's perfectly valid search result.

if (FileMaker::isError($result)) {
    if (! isset($result->code) || strlen(trim($result->code)) < 1) {
        echo '<tr>';
        echo '<td colspan="3">A System Error Occured</td>';
        echo '</tr>';
    } else {
        echo '<tr>';
        echo '<td colspan="3">No Records Found (Error Code: '.$result->code.')</td>';
        echo '</tr>';
    }
} else {
    $records = $result->getRecords();
    foreach ($records as $record) {
        echo '<tr>';
        echo '<td>' . $record->getField('Status') . '</td>';
        echo '<td>' . $record->getField('Type') . '</td>';
        echo '<td>' . $record->getField('Account Name') . '</td>';
        echo "</tr>";
    }
}

 

Edited by ggt667

  • Author

Thank you for the link! I modified the FileMaker::isError code, but the behavior is still the same. I also moved where the error is called on the page (attached). On the server I see a 401 error in the logs... Why does it bomb out when there is an error? Thank you, Brian

namesearch.php

Does the following output anything?

<?php
echo "Code: " . $result->code; 
#Check for an error
if( FileMaker::isError( $result ) ) {
?>

 

  • Author

With the open brace, the page fails entirely.

Without the brace, it loads on a found set, but only says "Code: " without any code number.

When no records are found, I get the header and nothing else (the "Code: " is not present!).

If I were you I'd create a new file with the following( still from the same link ) and adapt this to my database settings. To see if I could learn anything from this setup.

<?php

require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');
$request = $fm->newFindAllCommand('associate_layout');
$request->addSortRule('Status', 1);
$request->addSortRule('Type', 2);
$request->addSortRule('Account Name', 3);
$result = $request->execute();

echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
if (FileMaker::isError($result)) {
    if (! isset($result->code) || strlen(trim($result->code)) < 1) {
        echo '<tr>';
        echo '<td colspan="3">A System Error Occured</td>';
        echo '</tr>';
    } else {
        echo '<tr>';
        echo '<td colspan="3">No Records Found (Error Code: '.$result->code.')</td>';
        echo '</tr>';
    }
} else {
    $records = $result->getRecords();
    foreach ($records as $record) {
        echo '<tr>';
        echo '<td>' . $record->getField('Status') . '</td>';
        echo '<td>' . $record->getField('Type') . '</td>';
        echo '<td>' . $record->getField('Account Name') . '</td>';
        echo "</tr>";
    }
}
echo '</table>';

?>

 

  • Author

Thank you. I think it is now resolved. I "flipped" the code (before it was html with php, now it is php with html echoed), and found that the getRecords at the beginning of the file was creating a PHP FATAL error. Once that was moved to the else (like in your example), I stopped getting the FATAL error and got the 401 error I expected. Once again, thank you for your help!  Brian

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.