Note that there are some explanatory texts on larger screens.

plurals
  1. POphp not parsing file; Just returns code
    primarykey
    data
    text
    <p>I have got a problem where my class apparently is not being parsed correctly and the all files appear to be in place correctly.</p> <p>Here is my hierarchy:</p> <pre><code>| |_'_includes' |__classes |___class.login.php |___class.fmdb.php |__'fm_api' |___FileMaker.php | |_'public_html' |__login.php </code></pre> <p>(I hope that makes sense - the ones encapsulated in quotes are the folders)</p> <p>My problem is that apparently my code is not getting parsed correctly and the browser is just showing the class code.</p> <p>Here are my two classes where it reaches:</p> <p>class.login.php:</p> <pre><code>&lt;?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-&gt;fm = new FileMaker(constant('FMDB_NAME'), constant('FMDB_IP'), constant('FMDB_USERNAME'), constant('FMDB_PASSWORD')); $this-&gt;fmdb = new FMDB(); } } </code></pre> <p>class.fmdb.php:</p> <pre><code>&lt;?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-&gt;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 ) &gt; 0 return (FileMaker::isError($request_object) ? $request_object-&gt;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-&gt;select('someLayout', array( 'FieldName' =&gt; 'Value' ), true); * * @return array */ public function select($layout, $arrSearchCriteria) { $arrOut = array(); if ((!is_array($arrSearchCriteria))) { return false; } $findReq = $this-&gt;fm-&gt;newFindCommand($layout); foreach ($arrSearchCriteria as $field =&gt; $value) { $findReq-&gt;addFindCriterion($field, $value); } $results = $findReq-&gt;execute(); //Checks for an error if ($this-&gt;isError($results) === 0) { $records = $results-&gt;getRecords(); //Set the last layout used $this-&gt;layout = $layout; $this-&gt;lastObj = $records; foreach ($records as $record) { $arrOut[] = $record; foreach ($record-&gt;getFields() as $field) { $this-&gt;records[] = $field; } } } else { $arrOut['errorCode'] = $this-&gt;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-&gt;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-&gt;layout) : ($layout)); $records = $this-&gt;lastObj; // The record object is already initialised if (isset($records) &amp;&amp; !empty($records)) { foreach ($records as $record) { foreach ($arrFields as $fieldName =&gt; $value) { $setFields[] = $record-&gt;setField($fieldName, $value); } } $commit = $record-&gt;commit(); if ($this-&gt;isError($commit) === 0) { $blOut = true; } else { return $this-&gt;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-&gt;update('exampleLayout', array('Field1' =&gt; '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-&gt;fm-&gt;newFindCommand($layout); //Loops through setting the where clause foreach ($where as $field =&gt; $value) { $findReq-&gt;addFindCriterion($field, '==' . $value); } $result = $findReq-&gt;execute(); //Checks for errors if ($this-&gt;isError($result) === 0) { $result = $this-&gt;fm-&gt;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 =&gt; $v) { $record-&gt;setField($f, $v); } $commit = $record-&gt;commit(); } //Checking for errors if ($this-&gt;isError($commit) === 0) { $blOut = true; } else { return $this-&gt;isError($commit); } } else { return $this-&gt;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-&gt;fm-&gt;newAddCommand($layout, $arrFields); $result = $addCmd-&gt;commit(); if ($this-&gt;isError($result) === 0) { $blOut = true; } else { return $this-&gt;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-&gt;fm-&gt;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-&gt;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-&gt;fm-&gt;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-&gt;update :: $result = $this-&gt;fm-&gt;getRecordById($layout, $iRecordID); } /** * Gets the record ID from the current record * * @author RichardC * @since 1.0 * * @return int */ public function getRecordId() { return $this-&gt;lastObj-&gt;getRecordId(); } } ?&gt; </code></pre> <p>And this is what gets returned when I call the functions:</p> <p><img src="https://i.stack.imgur.com/hTOwV.png" alt="http://i.imgur.com/Tn7fh.png"></p> <p>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!</p> <p>Thanks!</p> <p><strong>[Edit]</strong></p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload