November 23, 201510 yr Hi guys, We are using FX.php to communicate with Filemaker as an interim measure as we develop a Drupal website. There are a number on non-Drupal HTML/PHP pages that use FX.php to talk to our Filemaker Server. However I am having trouble getting the pages to connect to Filemaker. This is the error I get: Fatal error: Cannot use object of type FX_Error as array in /mnt/gfs/acwa2djszbbyvu/sites/default/files/subsites/Pages/showfoundcourses.php on line 140 I have attached 2 files - a course search form and the php page that is supposed to display the search results. The code worked perfectly on Backspace our previous environment but its not working on Acquia.
November 23, 201510 yr I don't see the files, but this is generally a connection error. Try wrapping the code using the following (from Chris Hansen on the FX list): // the rest of your query code would be above this $qResult = $q->FMFind(); if (FX::isError($qResult)) { echo $qResult->getMessage(); } elseif ($qResult[‘errorCode’] != 0) { echo "A FileMaker error occurred ({$qResult[‘errorCode’]})"; } else { // your data set logic goes here }
November 23, 201510 yr Author Hi Webko, Thanks as always for your support. Im not sure what the dataset logic is defined as - can u insert your code into mine? Here's the code: <!doctype html> <html> <head> <meta charset="UTF-8"> <title></title> <!--boilerplate and normalize go first--> <!--<link rel="stylesheet" href="css/boilerplate.css" type="text/css" /> <link rel="stylesheet" href="css/normalize.css" type="text/css" />--> <!--ACWA/CCWT styles--> <!--<link rel="stylesheet" href="css/ccwtmain.css" type="text/css" />--> <!--<link rel="stylesheet" href="css/ccwtfonts.css" type="text/css" />--> <!--fonts from google--> <!--<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans"> <!--menu styles--> <!--<link rel="stylesheet" href="menu/primaryMenu.css" type="text/css"> <script src="/Pages/menu/primaryMenu.js" type="text/javascript"></script>--> <!--jQuery--> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> </head> <?php ini_set('display_errors', 1); //var_dump($user_data); error_reporting(E_ALL); //var_dump($config['db']); //exit(); //define('DEBUG', true); echo 'Hallo World'; //exit(); include_once('FX/FX.php'); include_once('FX/server_data.php'); echo 'Hallo World 2'; $course_search=$_REQUEST['course_search']; /*$newcd=$_REQUEST['newcd']; $cdn=$_REQUEST['cdn']; $course_name=$_REQUEST['course_name']; $course_code=$_REQUEST['course_code']; $starting_date=$_REQUEST['starting_date']; $venue=$_REQUEST['venue']; $presenters=$_REQUEST['presenters']; $stream=$_REQUEST['stream']; $keyword=$_REQUEST['keyword']; $semester=$_REQUEST['semester']; $type_of_search=$_REQUEST['type_of_search'];*/ if(isset($_REQUEST['skip'])){ $skipSize=$_REQUEST['skip']; }else{ $skipSize='0';} $groupSize='20'; if (isset($_REQUEST['page']) && is_numeric($_REQUEST['page'])) { $skipSize = $groupSize * ($_REQUEST['page'] -1); } $errors=array(); echo 'Hallo World 3'; if(($course_search == '') && ($course_name == '') && ($course_code == '') && ($presenters == '') && ($venue == '') && ($stream == '') && ($starting_date == '') && ($keyword == '') && ($cdn == '') && ($newcd == '') ) {$errors['course_name']= 'Please enter at least one search criteria.';} if($course_search != '' && strlen($course_search) > 200) {$errors['course_search']= 'The course search criteria is too long. Please edit this information.';} if($course_search != '' && preg_match('/^[a-zA-Z0-9\'\-\,\'\?\" ]+$/', $course_search) != 1) {$errors['course_search']= 'The course search criteria may only contain text and numbers.';} /*if($course_name != '' && strlen($course_name) > 200) {$errors['course_name']= 'The course name is too long. Please edit this information.';} if($course_name != '' && preg_match('/^[a-zA-Z0-9\'\-\,\'\?\" ]+$/', $course_name) != 1) {$errors['course_name']= 'The course name may only contain text.';} if($course_code != '' && strlen($course_code) > 12) {$errors['course_code']= 'The course code is too long. Please edit this information.';} if($course_code != '' && preg_match('/^[a-zA-Z0-9\'\-\,\'\?\" ]+$/', $course_code) != 1) {$errors['course_code']= 'The course code may only contain text.';} if($presenters != '' && strlen($presenters) > 100) {$errors['presenters']= 'The presenter name is too long. Please edit this information.';} if($presenters != '' && preg_match('/^[a-zA-Z0-9\'\-\,\' ]+$/', $presenters) != 1) {$errors['presenters']= 'The presenter name may only contain text.';} if($keyword != '' && strlen($keyword) > 200) {$errors['keyword']= 'The keyword is too long. Please edit this information.';} if($keyword != '' && preg_match('/^[a-zA-Z0-9\'\-\,\'\?\" ]+$/', $keyword) != 1) {$errors['keyword']= 'The keyword may only contain text.';} if (!empty($errors)){ include '/Pages/searchforcourses.php'; exit(); } */ $Course_Search=new FX($serverIP, $webCompanionPort, $dataSourceType); $Course_Search->SetDBData('Course Information','Course Information Search', $groupSize); $Course_Search->SetDBPassword('fmsadmin','fm$3rv3r'); echo 'Hallo World 4'; $date = explode('/', $starting_date); if(count($date)==3) $starting_date = $date[1] . '/' . $date[0] . '/' . $date[2]; /*if (! empty($newcd) ) $Course_Search->AddDBParam('New_Course', $newcd, 'eq'); if (! empty($cdn) ) $Course_Search->AddDBParam('CDN', $cdn, 'eq'); $Course_Search->AddDBParam('POST','Yes', 'eq'); $Course_Search->AddDBParam('Year','2015', 'gte'); if (! empty($course_name) ) $Course_Search->AddDBParam('Course_Name', $course_name, 'cn'); if (! empty($course_code) ) $Course_Search->AddDBParam('Course_Code', $course_code, 'eq'); if (! empty($starting_date) ) $Course_Search->AddDBParam('Course_Date_First', $starting_date, 'eq'); if (! empty($venue) ) $Course_Search->AddDBParam('Venue_Name', $venue, 'eq'); if (! empty($semester) ) $Course_Search->AddDBParam('Semester', $semester, 'eq'); if (! empty($stream) ) $Course_Search->AddDBParam('Stream_Name', $stream, 'eq'); if (! empty($keyword) ) $Course_Search->AddDBParam('Course_Outline', $keyword, 'cn'); if (! empty($presenters) ) $Course_Search->AddDBParam('All_Presenters', $presenters, 'eq'); if ($type_of_search == "OR") { $Course_Search -> AddDBParam('-lop', 'or'); }*/ if (! empty($course_search) ) $Course_Search->AddDBParam('Course_Search', $course_search, 'cn'); //$Course_Search->AddDBParam('customisedCourseDescriptionFlag', 'No', 'eq'); $Course_Search->AddSortParam('Sort_Order','descend'); $Course_Search->AddSortParam('Year','descend'); $Course_Search->AddSortParam('Course_Date_First','ascend'); $Course_Search->FMSkipRecords($skipSize); $Course_SearchResult=$Course_Search->FMFind(); $returnedCount=$Course_SearchResult['foundCount']; //echo $Course_SearchResult['errorCode']; foreach($Course_SearchResult['data'] as $key=>$Course_SearchData); $searchVariable=explode('.',$key); $currentRecord=$searchVariable[0]; if( $returnedCount == 0 ) { include_once('/Pages/nocoursesfound.html'); exit(); } ?> <body> <div class="wrapper"> <div class="container"> <div class="header"> <div class="navigation" id="menuInclude"><!--include menu from structure/menu.html here--> </div> </div> </div> <div class="container"> <div class="content"> <div class="sideNavContainer"> <nav id="sideInclude"><!--include menu from structure/side1.html here--> </nav> <div class="quicklinks"> <h2>Quick links</h2> <p><a href="http://acwa.dev.energetica.com.au/ccwt/house-services-we-come-you">In-house Training and Services</a></p> <p><a href="http://acwa.dev.energetica.com.au/ccwt/calendar/2015-acwa-e3-leadership-program-0">e3 Leadership Program</a></p> <p><a href="http://acwa.dev.energetica.com.au/ccwt/training/qualifications/bsb51107-diploma-management">Fast Track Diploma of Management</a></p> <p><a href="http://acwa.dev.energetica.com.au/ccwt/specialist-programs/rgf-statewide-training-project">Responsible Gambling Fund</a></p> </div> </div> <div style="padding-top:20px;"></div> <div class="bodyContent"> <a href="http://acwa.dev.energetica.com.au">Home</a> » <a href="http://acwa.dev.energetica.com.au/ccwt/ccwt-home">CCWT</a> » <a href="http://acwa.dev.energetica.com.au/ccwt/calendar-training-ccwt">Calendar</a> » Course Search Results <h2>Course Search Results</h2> Page: <?php $pages=ceil($returnedCount/$groupSize); if($pages>'1'){ $i='1'; $x='0'; ?> <a href="/Pages/showfoundcourses.php?page=<?php echo $i; ?>&course_search=<?php echo urlencode($course_search); ?>&course_name=<?php echo urlencode($course_name); ?>&course_code=<?php echo urlencode($course_code); ?>&starting_date=<?php echo urlencode($starting_date); ?>&venue=<?php echo urlencode($venue); ?>&presenters=<?php echo urlencode($presenters); ?>&stream=<?php echo urlencode($stream); ?>&type_of_search=<?php echo urlencode($type_of_search); ?>&keyword=<?php echo urlencode($keyword); ?>&venueinformation=<?php echo urlencode($venue_information); ?>"><?php echo $i; ?></a> <?php while($i++<$pages){ $x=$i*$groupSize; echo ' | ' ?> <a href="/Pages/showfoundcourses.php?page=<?php echo $i; ?>&course_search=<?php echo urlencode($course_search); ?>&course_name=<?php echo urlencode($course_name); ?>&course_code=<?php echo urlencode($course_code); ?>&starting_date=<?php echo urlencode($starting_date); ?>&venue=<?php echo urlencode($venue); ?>&presenters=<?php echo urlencode($presenters); ?>&stream=<?php echo urlencode($stream); ?>&type_of_search=<?php echo urlencode($type_of_search); ?>&keyword=<?php echo urlencode($keyword); ?>&semester=<?php echo urlencode($semester); ?>"><?php echo $i; ?></a> <?php } } ?> <BR><BR> <table class="searchtable" width="700" border="0" cellpadding="3" cellspacing="1"> <tr valign="bottom"> <th width="247">Course Name (Code)<br> </th> <th width="139">Course Dates</th> <th width="134">Venue Name<br> </th> <th width="159">Presenters<br> </font></th> </tr> <?php foreach($Course_SearchResult['data'] as $key=>$Course_SearchData){ $searchVariable=explode('.',$key); $currentRecord=$searchVariable[0]; $course_URL = "/Pages/coursedetails.php?recid=$currentRecord"; if ($Course_SearchData['legalOOHC'][0] == 'X') $course_URL = "/Pages/coursedetailsoohc.php"; else if ($Course_SearchData['Course_Capacity'][0] == 'Course Finished') $course_URL = "/Pages/coursedetailsonly.php?recid=$currentRecord"; else if ($Course_SearchData['Course_Capacity'][0] == 'Course Has Started') $course_URL = "/Pages/coursedetailsonly.php?recid=$currentRecord"; else if ($Course_SearchData['Rescheduled'][0] == 'X') $course_URL = "/Pages/courserescheduled.php?recid=$currentRecord"; else if ($Course_SearchData['Cancelled'][0] == 'X') $course_URL = "/Pages/coursedetailsonly.php?recid=$currentRecord"; else if ($Course_SearchData['Course_Capacity'][0] == 'Full/Join Waiting List' && $Course_SearchData['Registration_Code'][0] == 'ALLFREE') $course_URL = "/Pages/coursedetailsfreewl.php?recid=$currentRecord"; else if ($Course_SearchData['Course_Capacity'][0] == 'Full/Join Waiting List' && $Course_SearchData['Registration_Code'][0] == 'PAYFREE') $course_URL = "/Pages/coursedetailswlpof.php?recid=$currentRecord"; else if ($Course_SearchData['Course_Capacity'][0] == 'Full/Join Waiting List') $course_URL = "/Pages/coursedetailswl.php?recid=$currentRecord"; else if ($Course_SearchData['Registration_Code'][0] == 'PAYFREE') $course_URL = "/Pages/coursedetailspof.php?recid=$currentRecord"; else if ($Course_SearchData['Registration_Code'][0] == 'PAYFTNFREE') $course_URL = "/Pages/coursedetailsptf.php?recid=$currentRecord"; else if ($Course_SearchData['Registration_Code'][0] == 'ALLFREE') $course_URL = "/Pages/coursedetailsnopayment.php?recid=$currentRecord"; else if ($Course_SearchData['Registration_Code'][0] == 'IDAT') $course_URL = "/Pages/coursedetailsidat.php?recid=$currentRecord"; else if ($Course_SearchData['Registration_Code'][0] == 'CAS') $course_URL = "/Pages/coursedetailscas.php?recid=$currentRecord"; else if ($Course_SearchData['Special_Course_1'][0] == 'FORUM1') $course_URL = "/Pages/coursedetailsforum11a.php?recid=$currentRecord"; else if ($Course_SearchData['Special_Course_1'][0] == 'FORUM2') $course_URL = "/Pages/coursedetailsforum11b.php?recid=$currentRecord"; else if ($Course_SearchData['Special_Course_1'][0] == 'YSD') $course_URL = "/Pages/coursedetailsonly.php?recid=$currentRecord"; ?> <tr height="38"> <td valign="top" width="247" height="38"><a href="<?php echo $course_URL; ?>"><?php echo $Course_SearchData['Course_Name'][0]; ?> (<?php echo $Course_SearchData['Course_Code'][0]; ?>)</a> <span class="fineprint"> <?php if ($Course_SearchData['Restricted_Audience'][0] != '') { echo '<br>' . $Course_SearchData['Restricted_Audience'][0]; } ?> <br> <?php echo $Course_SearchData['Course_Capacity'][0]; ?><br> </span></td> <td valign="top" width="139" height="38"> <?php if ($Course_SearchData['Course_Length_Days'][0] == '') { echo 'Not applicable'; } else { echo $Course_SearchData['Course_Length_Days'][0] . ':<br />' . $Course_SearchData['All_Course_Dates'][0]; } ?> </td> <td valign="top" width="134" height="38"> <a href="/Pages/trainingvenues.php?venue=<?php echo $Course_SearchData['Venue_Name'][0]; ?>"><?php echo $Course_SearchData['Venue_Name'][0]; ?></a></font></td> <td valign="top" width="159" height="38"> <?php if ($Course_SearchData['All_Presenters'][0] == "Not applicable") { echo 'Not applicable'; } else { echo '<a href="/Pages/presenterinformation.php?recid=' . $currentRecord . '">' . $Course_SearchData['All_Presenters'][0] . '</a>'; } ?> </td> </tr> <?php } ?> <tr height="50"> <td></td> <td> </td> <td></td> <td></td> <td> </td> </tr> </table> </div> <div class="clearLine"></div> </div> </div> <div class="footer"> <div class="container"> <div class="footerContents"> <div class="iconContainer"> <div class="icon"><img src="images/facebook.gif"></div> <div class="icon"><img src="images/twitter.gif"></div> <div class="icon"><img src="images/pdf.gif"></div> </div> <nav class="footerNavContainer"> <UL class="footerNav"> <LI><a href="http://acwa.dev.energetica.com.au">ACWA Home</a></LI> <LI><a href="http://acwa.dev.energetica.com.au/ccwt/ccwt-home">CCWT Home</a></LI> <LI><a href="http://acwa.dev.energetica.com.au/sitemap.xml">Site map</a></LI> <LI><a href="http://acwa.dev.energetica.com.au/acwa/about/contact-us">Contact Us</a></LI> <LI class="last"><a href="http://acwa.dev.energetica.com.au/acwa/legal-information">Legal information</a></LI> </UL> </nav> </div> </div> </div> </div> <!--scripts--> <script> <!--includes tier 1 menu from structure/menu.html--> $(function(){ $("#menuInclude").load("/Pages/structure/menu.html"); $("#sideInclude").load("/Pages/structure/side1.html"); }); </script> <!--end scripts--> </body> </html>
November 23, 201510 yr OK, Some notes - I've stripped out all the html for testing. And all the commented out code for the moment $date relies on a non-existing variable $starting_date - removed from the moment And: if (! empty($course_search) ) $Course_Search->AddDBParam('Course_Search', $course_search, 'cn'); Looks like invalid php - which may trigger this - removed the if statement... So, the much cut down version (still without the error checking above) - try this and see what happens: <?php ini_set('display_errors', 1); error_reporting(E_ALL); include_once('FX/FX.php'); include_once('FX/server_data.php'); $course_search=$_REQUEST['course_search']; if(isset($_REQUEST['skip'])){ $skipSize=$_REQUEST['skip']; } else { $skipSize='0'; } $groupSize='20'; if (isset($_REQUEST['page']) && is_numeric($_REQUEST['page'])) { $skipSize = $groupSize * ($_REQUEST['page'] -1); } $errors=array(); if(($course_search == '') && ($course_name == '') && ($course_code == '') && ($presenters == '') && ($venue == '') && ($stream == '') && ($starting_date == '') && ($keyword == '') && ($cdn == '') && ($newcd == '') ) {$errors['course_name']= 'Please enter at least one search criteria.';} if($course_search != '' && strlen($course_search) > 200) {$errors['course_search']= 'The course search criteria is too long. Please edit this information.';} if($course_search != '' && preg_match('/^[a-zA-Z0-9\'\-\,\'\?\" ]+$/', $course_search) != 1) {$errors['course_search']= 'The course search criteria may only contain text and numbers.';} $Course_Search=new FX($serverIP, $webCompanionPort, $dataSourceType); $Course_Search->SetDBData('Course Information','Course Information Search', $groupSize); $Course_Search->SetDBPassword('fmsadmin','fm$3rv3r'); $Course_Search->AddDBParam('Course_Search', $course_search, 'cn'; $Course_Search->AddSortParam('Sort_Order','descend'); $Course_Search->AddSortParam('Year','descend'); $Course_Search->AddSortParam('Course_Date_First','ascend'); $Course_Search->FMSkipRecords($skipSize); $Course_SearchResult=$Course_Search->FMFind(); $returnedCount=$Course_SearchResult['foundCount']; echo "Found: ".$returnedCount; foreach($Course_SearchResult['data'] as $key=>$Course_SearchData); $searchVariable=explode('.',$key); $currentRecord=$searchVariable[0]; ?>
November 23, 201510 yr Author Hi Webko Ive messaged you my full reply as Ive sent the server_data.php file which as security data. 6 minutes ago, brainonastick said: Hi Webko Ive messaged you my full reply as Ive sent the server_data.php file which as security data. Also is it worth me digging out the phpinfo.php file on Acquia to see if theres any bad settings for PHP?
November 24, 201510 yr Are you able to connect to your database using the example files that comes with FX.php? https://github.com/yodarunamok/fxphp/blob/master/Tutorials/FXExamples.php Usually the error you describe are from wrong login credentials or a missing include IIRC... Edited November 24, 201510 yr by ggt667
November 24, 201510 yr we did some further testing offline - the FX error object throws "FX: ExecuteQuery XML error: Invalid document end at line 2" - looks like there is an issue with the server setup... Cheers Webko
November 24, 201510 yr Author Thank you again Webko your being so generous with your time - we are now sorting out some server issues. One thing - when Filemaker changed file extensions to .fmp12 we dropped the file extension from the SetDBData and used $dataSourceType instead of 'FMPro7' in new FX, e.g.: $Course_Search=new FX($serverIP, $webCompanionPort, $dataSourceType //not 'FMPro 7'); $Course_Search->SetDBData('Course Information' //not .fmp12,'Course Information Search', $groupSize); $Course_Search->SetDBPassword($webPW,$webUN); I assume this is OK - it works in our current set up.
November 24, 201510 yr Dear Steven, You defined $dataSourceType as being: $dataSourceType = 'FMPro7'; And I have never used the file extension when addressing a file through FX ;-) All the best Webko
November 25, 201510 yr Author Hi Webko, I learned basic PHP from FMWebschools manual (2006) and they used to add the .fp7 extension when calling the database. I think we're a step closer to getting the database to respond. The only error now is:Notice: Undefined variable: key in /mnt/gfs/acwa2djszbbyvu/sites/default/files/subsites/Pages/showfoundcourses.php on line 138802 Heres the code where the error is pointing to: 131 $Course_Search->FMSkipRecords($skipSize); 133 $Course_SearchResult=$Course_Search->FMFind(); 134 $returnedCount=$Course_SearchResult['foundCount']; 136 foreach($Course_SearchResult['data'] as $key=>$Course_SearchData); 138 $searchVariable=explode('.', $key); 139 $currentRecord=$searchVariable[0]; 141 echo $Course_SearchResult['errorCode']; But we have an issue with the databases not appearing on the test server after being shared to them so I will sort this out and see how we go from there. Thanks again.
November 25, 201510 yr 15 hours ago, webko said: Dear Steven, You defined $dataSourceType as being: $dataSourceType = 'FMPro7'; And I have never used the file extension when addressing a file through FX ;-) Because we made reasonable default settings for that option? var $dataServerType = 'fmpro'; var $dataServerVersion = 7; Edited November 25, 201510 yr by ggt667
November 25, 201510 yr Author 5 hours ago, ggt667 said: Because we made reasonable default settings for that option? var $dataServerType = 'fmpro'; var $dataServerVersion = 7; Thanks ggt667, Do I put the above code into the server_data.php file? And do I leave var $dataServerVersion =7? We are using v13 atm and going to 14 shortly.
November 27, 201510 yr On 25 November, 2015 21:06:46, brainonastick said: Thanks ggt667, Do I put the above code into the server_data.php file? And do I leave var $dataServerVersion =7? We are using v13 atm and going to 14 shortly. I just quoted the default values that FX.php will use if none are set.
Create an account or sign in to comment