Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6846819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:40:13+00:00 2026-05-27T00:40:13+00:00

I have got a problem where my class apparently is not being parsed correctly

  • 0

I have got a problem where my class apparently is not being parsed correctly and the all files appear to be in place correctly.

Here is my hierarchy:

|
|_'_includes'
|__classes
|___class.login.php
|___class.fmdb.php
|__'fm_api'
|___FileMaker.php
|
|_'public_html'
|__login.php

(I hope that makes sense – the ones encapsulated in quotes are the folders)

My problem is that apparently my code is not getting parsed correctly and the browser is just showing the class code.

Here are my two classes where it reaches:

class.login.php:

<?php

require_once ('config/config.constants.php');
require_once ('classes/class.fmdb.php');
/**
 * Performs all the Login actions
 *
 * @author RichardC
 */
class Login {

    protected $fm;
    protected $fmdb;

    public function __construct() {
        $this->fm = new FileMaker(constant('FMDB_NAME'), constant('FMDB_IP'), constant('FMDB_USERNAME'), constant('FMDB_PASSWORD'));
        $this->fmdb = new FMDB();
    }
}

class.fmdb.php:

<?php

require_once ('fm_api/FileMaker.php');
/**
 * Database interface for the Scheduler
 *
 * @author RichardC
 */
class FMDB {

    /**
     * Setting the class-wide variables
     */
    protected $fm;
    protected $layout = '';
    protected $records = array();

    public $lastObj = null;


    /**
     * The constructor of the class
     */
    public function __construct() {
        $this->fm = new FileMaker(FMDB_NAME, FMDB_IP, FMDB_USERNAME, FMDB_PASSWORD);
    }

    /**
     * Returns an Error if there is one, for example: error 401 (record missing)
     * 
     * @author  RichardC 
     * @since   1.0
     * 
     * @version 2.0
     * 
     * @param obj    $request_object
     * 
     * @return int (error Code || 0 on no error)
     */
    public static function isError($request_object) {
        //The reason it returns 0 instead of false is due to the getCode() method, which will return the original error code so you can check if isError( $res ) > 0
        return (FileMaker::isError($request_object) ? $request_object->getCode() : 0);
    }

    /**
     * Selects data from a FileMaker Database
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @param string    $layout
     * @param array     $arrSearchCriteria
     * @param bool      $recordId (true to get the Record ID or false to ignore)
     * 
     * @example $objScheduler->select('someLayout', array( 'FieldName'  =>  'Value' ), true);
     * 
     * @return array
     */
    public function select($layout, $arrSearchCriteria) {

        $arrOut = array();

        if ((!is_array($arrSearchCriteria))) {
            return false;
        }

        $findReq = $this->fm->newFindCommand($layout);

        foreach ($arrSearchCriteria as $field => $value) {
            $findReq->addFindCriterion($field, $value);
        }

        $results = $findReq->execute();

        //Checks for an error
        if ($this->isError($results) === 0) {
            $records = $results->getRecords();

            //Set the last layout used
            $this->layout = $layout;
            $this->lastObj = $records;

            foreach ($records as $record) {

                $arrOut[] = $record;

                foreach ($record->getFields() as $field) {
                    $this->records[] = $field;
                }
            }
        } else {
            $arrOut['errorCode'] = $this->isError($results);
        }

        return $arrOut;
    }

    /**
     * Secures a string using mysql_real_escape_string and htmlentities
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @param string $string
     * 
     * @return string
     */
    public function fm_escape_string($string) {
        return mysql_real_escape_string(htmlentities($string));
    }

    /**
     * Get the records returned by the Select in an array
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @return  array
     */
    public function getRecords() {
        return $this->records;
    }

    /**
     * Set fields by in the Layout with the given fields and values
     *
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.2
     * 
     * @param array     $arrFields 
     * 
     * @note    If you want to specify a layout, please use the update function.
     * 
     * @return  boolean
     */
    public function setFields($arrFields) {

        $blOut = false;

        if ((!is_array($arrFields))) {
            return false;
        }

        $layout = (empty($layout) ? ($this->layout) : ($layout));
        $records = $this->lastObj;

        // The record object is already initialised
        if (isset($records) && !empty($records)) {

            foreach ($records as $record) {
                foreach ($arrFields as $fieldName => $value) {

                    $setFields[] = $record->setField($fieldName, $value);
                }
            }

            $commit = $record->commit();

            if ($this->isError($commit) === 0) {
                $blOut = true;
            } else {
                return $this->isError($commit);
            }
        }

        //Speed things up
        unset($record, $commit, $fieldName, $value);

        return $blOut;
    }


    /**
     * Update the fields on a layout with specified data
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @param   string  $layout
     * @param   array   $arrFields
     * @param   int     $iRecordID
     * 
     * @example $objFM->update('exampleLayout', array('Field1' => 'This is the data which Field1 will be updated with'), 1);
     * 
     * @return  boolean
     */
    public function updateRecordByID($layout, $arrFields, $iRecordID) {
        $blOut = false;

        if (($layout == '') || (!is_array($arrFields)) || (!is_number($iRecordID))) {
            return false;
        }

        $findReq = $this->fm->newFindCommand($layout);

        //Loops through setting the where clause
        foreach ($where as $field => $value) {
            $findReq->addFindCriterion($field, '==' . $value);
        }

        $result = $findReq->execute();

        //Checks for errors
        if ($this->isError($result) === 0) {
            $result = $this->fm->getRecordById($layout, $iRecordID);

            //Loops through each result from the 'Select'
            foreach ($records as $record) {
                //Loops through all given fields and values, setting the fields to be said values
                foreach ($arrRecords as $f => $v) {
                    $record->setField($f, $v);
                }
                $commit = $record->commit();
            }
            //Checking for errors
            if ($this->isError($commit) === 0) {
                $blOut = true;
            } else {
                return $this->isError($commit);
            }
        } else {
            return $this->isError($result);
        }

        // Speed things up
        unset($result, $commit, $record, $findReq);

        return $blOut;
    }

    /**
     * Inserts a record into the Table/Layout with the given data from $arrFields
     *
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @param string $layout
     * @param array  $arrFields
     * 
     * @return boolean 
     */
    public function insert($layout, $arrFields) {

        $blOut = false;

        if (($layout == '') || (!is_array($arrFields))) {
            return false;
        }

        $addCmd = $this->fm->newAddCommand($layout, $arrFields);
        $result = $addCmd->commit();

        if ($this->isError($result) === 0) {
            $blOut = true;
        } else {
            return $this->isError($result);
        }

        //Speed things up
        unset($addCmd, $result);

        return $blOut;
    }

    /**
     * List Layout Names from Database
     *
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @return array
     */
    public function get_layout_names() {
        return $this->fm->listLayouts();
    }

    /**
     * Alias of the select function
     *
     * @author RichardC
     * @since  1.0
     * 
     * @version 1.0
     * 
     * @param string $layout
     * @param array  $arrSearchCriteria
     * 
     * @return array
     */
    public function find($layout, $arrSearchCriteria) {
        return $this->select($layout, $arrSearchCriteria);
    }

    /**
     * Returns the number of rows in a given query
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @param array $arrResult
     * 
     * @return int 
     */
    public function fm_num_rows($arrResult) {
        return (!is_array($arrResult) ? 0 : count($arrResult));
    }


    /**
     * Runs a script on the server from the web
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     *
     * @param string $layout
     * @param string $scriptName 
     * @param array  $params (Optional depending on the script params that you wish to execute)
     * 
     * return boolean
     */
    public function runScript($layout, $scriptName, $params = array()) {
        $blOut = false;

        if ((empty($layout)) || (empty($scriptName))) {
            return $blOut;
        }

        if ($this->fm->newPerformScriptCommand($layout, $scriptName, $params)) {
            $blOut = true;
        }

        return $blOut;
    }

    /**
     * Rec-ID (FileMaker Record ID hidden field)
     * 
     * LayoutName, Field Value, FieldName
     */
    public function getLastID() {

    }

    public function delete($layout, $iRecordID) {
        // Example from $this->update :: $result = $this->fm->getRecordById($layout, $iRecordID);
    }

    /**
     * Gets the record ID from the current record
     *
     * @author  RichardC
     * @since   1.0
     * 
     * @return int 
     */

    public function getRecordId() {
        return $this->lastObj->getRecordId();
    }
}

?>

And this is what gets returned when I call the functions:

http://i.imgur.com/Tn7fh.png

For reasons that some of this is confidential due to its nature I cannot show you all of the code, but any suggestions on why this may be happening would be a great help!

Thanks!

[Edit]

Sorry, the code I show are only snippets of each class. I cannot post the full class code as it is a work-related project.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:40:13+00:00Added an answer on May 27, 2026 at 12:40 am

    you have no closing php tag? ?>, although it’s optional it might be necessary since your including other files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a philosophical programming problem. Let's say I have a class named Employees.
I've got a problem I'm not sure how best to solve. I have an
I have got a problem here in terminating the threads. The problem is that
I have got a problem and a solution, but I am not really satisfied
Guys, I have got a slightly different problem with Java Dynamic class loading. I
I have got a problem with my actionscript class. This is my code: package
I have got a weird problem here, and more interesting that it works fine
I have got a strange and rare problem here. I am using NSTimer event
I have got a problem with calling a global function, which takes a pointer
I have got the following problem since the server has safe mode turned on,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.