Brian Paquin Posted November 1, 2013 Posted November 1, 2013 Using FileMaker Server 11 for a Users database and I have setup a website (using PHP) for people to search the database. Searches (and results) are working properly, but I can't get an error message when no results are found. When this happens, I get the top part of the web page, but then nothing else (the page has a mix of PHP and HTML)... Ideas? (header with stylesheet information removed) <div id="container"> <div id="top"><a href="http://medicine.yale.edu/pathology/index.aspx">Yale Department of Pathology</a></div> <!-- end #top --> <div id="header">Yale Pathology Directory</div> <!-- end #header --> <div id="mainContent"> <?php include ("dbaccess.php"); $today = date("m/d/y"); $HasLeft = 'No'; $FirstName = $_GET['Users::FirstName']; $LastName = $_GET['Users::LastName']; $layout =& $fm->getLayout('Users'); $findCommand =& $fm->newFindCommand('Users'); $findCommand->setRange(0, 400); $findCommand->addFindCriterion('FirstName', $FirstName); $findCommand->addFindCriterion('LastName', $LastName); $findCommand->addFindCriterion('HasLeft', $HasLeft); $findCommand->addSortRule('LastName', 1, FILEMAKER_SORT_ASCEND); $findCommand->addSortRule('FirstName', 2, FILEMAKER_SORT_ASCEND); $result = $findCommand->execute(); $records = $result->getRecords(); $unitvalues = $layout->getValueListTwoFields('UnitSubUnit'); #Check for an error if (FileMaker::isError($result)) { echo "<p>Error: " . $result->getMessage() . "</p>"; exit; } ?> <table> <tr> <td width="250"> <form action="namesearch.php" method="get"> <font size="-1">First:</font> <input id="FirstName" type="text" name="Users::FirstName"/> <br> <font size="-1">Last:</font> <input id="LastName" type="text" name="Users::LastName"/> <input type="submit" name="submit" value="Find"/> </form> </td> <td width="200"> <font size="-1">Unit - SubUnit search:</font> <form method="get" action="unitsearch.php" name="unitsearch"> <select id="type" name="UnitSubUnit" size="1" onchange="document.forms['unitsearch'].submit();"> <option value=""></option> <?php foreach($unitvalues as $value) { ?> <option value="<?php echo $value; ?>"><?php echo $value; ?></option> <?php } ?> </select> </form> </td> <td width="100" align="center"> <font size="-1"><a href="http://intranet.yalepath.org/directory/index.php">Home</a></font> </td> </tr> </table> <br> (more code to display search results - a table for the results and then a footer) Brian
doughemi Posted November 1, 2013 Posted November 1, 2013 Change this portion of your code: #Check for an error $NoneFoundMsg = ''; if (FileMaker::isError($result)) { if $result->code != 401{ echo "<p>Error: " . $result->getMessage() . "</p>"; exit; } else { //code 401 is no records found $NoneFoundMsg = 'No records found'; } You will have to account for !empty($NoneFoundMsg) when you are displaying your results.
Recommended Posts
This topic is 4295 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now