0 Replies Latest reply on May 21, 2017 8:58 AM by jamescv31

    Weird Error that causes problem with Filemaker PHP API

    jamescv31

      Greetings

       

      Why all of a sudden where the PHP API turns out crazy in the following situation?

       

      1) If more than two types of functions API, then it will result to error.

      2) Why those source codes are work well if the records are less than 1000+ despite of simultaneous API functions included?

       

      require_once('FileMaker.php');

       

       

      $fm = new FileMaker();

      $fm->setProperty('database', 'PFAM NEW');

      $fm->setProperty('hostspec', 'armontsys.ddns.net');

      $fm->setProperty('username', 'Admin');

      $fm->setProperty('password', 'enzio');

       

       

        $inactive = "Inactive";

        $request_inactive = $fm->newFindCommand('ContactManagement');

        $request_inactive->addFindCriterion('activeFormatText', $inactive);

       

       

        $resultinactive = $request_inactive->execute();

          if (FileMaker::isError($resultinactive))

        {

        echo "<p>" . $resultinactive ->getMessage() . "</p>";

        exit;

      }

      echo$resultinactive;

      This piece of code suppose to show the total foundset records which match on the 'keyword' "inactive" records.

       

      But it cannot display the result and instead different errors like Communication Error.

       

      ----------------------

      But when it comes on navigation then it will work correctly without issue but inserting different API function then it will just load forever.

       

      if(empty($_GET['Com']))

        {

       

       

       

          $FirstName = "";

          $request = $fm->newFindCommand('ContactManagement');

          $request->addFindCriterion('activeFormatText', "Active");

       

       

       

       

        }

       

       

      if(empty($_GET['skip']))

        {

        $skip=0; // Default shows the first record

        }

        else

        {

        $skip=$_GET['skip'];

        }

      if(empty($_GET['max']))

        {

        $max=1; // Default for record navigation is 1 record at time

        }

        else

        {

        $max=$_GET['max'];

        }

      $request->setRange($skip, $max);

       

       

      # Execute the find request

      $result = $request->execute();

       

       

      if (FileMaker::isError($result))

        {

        echo "<p>" . $result->getMessage() . "</p>";

        exit;

        }

       

       

       

       

       

       

      # Get the result record set as an array of record objects. This is technically your found set of records.

      $records = $result->getRecords();

       

       

       

       

      if(empty($_GET['skip']) or empty($_GET['max']))

        {

        $currentRecord = 1;

        }

        else

        {

        $currentRecord = $_GET['skip'] + $_GET['max'];

        }

      $found = $result->getFoundSetCount();

      $total = $result->getTableRecordCount();

       

       

      //echo '<p>Record ' . $currentRecord . ' of '. $total . ' Total Records<p>';

       

       

      //echo '<h3 id="totalrecords"> Record ' . $currentRecord . ' of ' . $found;

       

       

      /* Connection of FileMaker API */

       

       

      ?>

       

       

       

       

       

       

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

       

       

      <html>

        <head>

        <!-- <jdoc:include type="head" /> -->

              <script type="text/javascript" src="http://www.datejs.com/build/date.js"></script>

              <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

       

       

        <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">

        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

        <meta name="HandheldFriendly" content="true">

        <link rel="stylesheet" href="index_design.css">

        <title> Phoenix Fire Protection Image </title>

        </head>

       

       

      <header>

        <!-- header Image -->

       

       

        <div id="Imageheader">

        <!-- Mobile Phones header -->

        <img src="images/mobile_header_smartphones.png" alt="PhoenixMobilestlye" id="imagemobileadjust"/>

        <!-- Mobile Phones header -->

        </div>

        <!-- Header Image -->

       

       

       

       

        <!-- Status Records -->

       

       

        <h3 id="totalrecords"> Record <?php echo $currentRecord . ' of ' . $found; ?> </h3>

       

       

       

       

      <?php

       

       

      /* Continuation navigation links */

       

       

      if(empty($_GET['Com']))

         {

         $firstName='';

         }

         else

         {

         $firstName=$_GET['Com'];

         }

       

         #skip = $_GET['skip'];

         if(empty($_GET['skip']))

         {

         $skip='0';

         }

         else

         {

         $skip=$_GET['skip'];

         }

       

       

      # FIRST RECORD

        if ($skip > 0 )

        {

        //echo '<a href="' . $_SERVER['PHP_SELF'] . '?skip=0&max=1&FirstName=' . $firstName . '"><img src="Images/first_record.jpg" border=0/></a>';

       

       

        echo '<a href="' . $_SERVER['PHP_SELF'] . '?skip=0&max=1&FirstName=' . $firstName . '"><img src = "Pagination_Records/leftfirst.png" onMouseOver=src="Pagination_Records/leftfirsthover.png" onMouseOut=src="Pagination_Records/leftfirst.png" alt="first" id="first"/></a>';

       

       

        }

        else

        {

       

       

       

       

       

       

       

        //echo '<img src="Images/first_record.jpg" border=0/>';

        }

        ?>

        </td>

          <td>

        <?php

        # PREVIOUS RECORD

        $previous = $skip-1;

        if ($skip > 0)

        {

        //echo '<a href="' . $_SERVER['PHP_SELF'] . '?skip=' . $previous . '&max=1&FirstName=' . $firstName . '"><img src="Images/previous_record.jpg" border=0/></a>';

       

       

        echo '<a href="' . $_SERVER['PHP_SELF'] . '?skip=' . $previous . '&max=1&FirstName=' . $firstName . '"> <img src = "Pagination_Records/left.png" onMouseOver=src="Pagination_Records/lefthover.png" onMouseOut=src="Pagination_Records/left.png" alt="prev" id="prev"/> </a>';

        }

        else

        {

        //echo '<img src="Images/previous_record.jpg" border=0/>';

       

       

       

        }

        ?>

        </td>

          <td>

        <?php

        #NEXT RECORD

        $next = $skip+1;

        if ($skip+1 < $found)

        {

        //echo '<a href="' . $_SERVER['PHP_SELF'] . '?skip=' . $next . '&max=1&FirstName=' . $firstName . '"><img src="Images/next_record.jpg" border=0/></a>';

       

       

        echo '<a href="' . $_SERVER['PHP_SELF'] . '?skip=' . $next . '&max=1&FirstName=' . $firstName . '"> <img src = "Pagination_Records/right.png" onMouseOver=src="Pagination_Records/righthover.png" onMouseOut=src="Pagination_Records/right.png" alt="next" id="next"/></a>';

        }

       

       

       

       

        else

        {

        //echo '<img src="Images/next_record.jpg" border=0/>';

       

       

       

       

       

       

        }

        ?>

        </td>

          <td>

        <?php

        #LAST RECORD

        $last = $found-1;

        if ($skip+1 < $found)

        {

        //echo '<a href="' . $_SERVER['PHP_SELF'] . '?skip=' . $last . '&max=1&FirstName=' . $firstName . '"><img src="Images/last_record.jpg" border=0/></a>';

       

       

       

       

        echo '<a href="' . $_SERVER['PHP_SELF'] . '?skip=' . $last . '&max=1&FirstName=' . $firstName . '"><img src = "Pagination_Records/rightlast.png" onMouseOver=src="Pagination_Records/rightlasthover.png" onMouseOut=src="Pagination_Records/rightlast.png" alt="last" id="last"/></a>';

        }

        else

        {

        //echo '<img src="Images/last_record.jpg" border=0/>';

        }

       

       

       

       

      /* Continuation navigation links */

       

       

       

       

      ?>