AnsweredAssumed Answered

Generic 500 Error with PHP API

Question asked by JoshuaNelson on Nov 19, 2014
Latest reply on Dec 10, 2014 by erawson

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.

Outcomes