1 Reply Latest reply on Dec 10, 2014 10:35 AM by erawson

    Generic 500 Error with PHP API

    JoshuaNelson

      Title

      Generic 500 Error with PHP API

      Your post

      Sorry if this is straightforward, but I'm pretty new to Filemaker: I'm designing a simple POST form in order to search a database and return a count of entries. However, whenever the html form is submitted, a 500 Internal Server Error is returned. The code is fairly simple at this point, so the opportunities for it to go wrong are somewhat limited. I've attached the source code below:

      
      <?php
      
          require_once ('FileMaker.php');
      
          $server = 'https://sample';
          $username = 'web';
          $password = 'web';
          $layout = 'php_1';
          
          $fm = new FileMaker('Alumni', $server, $username, $password);
          
          function counter(){
              
              $name = $_POST["name"];
                                          
              $findCommand =& $fm->newFindCommand($layout);
              $findCommand->addFindCriterion('NameLast', $name);
              $result = $findCommand->execute();
              $count = count($result);
                  
              echo $count . ' record(s) found.';
              
          }//end counter()
      ?>
      
      <html>
          <body>
              <h2>Search</h2>
              <div id="content_cont">  
                  <form action="file.php" method="post" name="search" id="search">
                      Last Name: <input type="text" name="name"> 
                      <input type="submit" value="Search by name" name="submit">
                  </form>
                  <hr>
                  <?php
                      if( isset( $_POST['submit'] ) ) {
                          counter();
                      }//end if
                  ?>
              </div>
          </body>
      </html>

      Any help is appreciated, thank you.

        • 1. Re: Generic 500 Error with PHP API
          erawson

          The issue is likely related to your $server variable. This should be the IP address / hostname of the filemaker server's web publishing engine. e.g. $server = 'localhost' or $server = '10.10.5.5'

          on an unrelated note, in your counter function instead of doing count($result) you may want to use $result->getFetchCount() or $result->getFoundSetCount()