[FX.php List] Re: FX.php_List Digest, Vol 114, Issue 14

LELAND LONG lelandlong at me.com
Wed Mar 19 14:46:06 MDT 2014


I think you may be experiencing the same pain I did when moving from FX v4.x to v6.x. 

What I found in this forum is that the amount of pain you feel when doing this conversion is based solely upon you're programming style (how you implemented the FX functions on your page). Some people have expressed no pain in converting but I think their coding and the way they use the FX functions are different than mine and therefore our experiences differ.

Looking at the code example you provided I am going to offer code snippets that I changed in my code that eliminated this error for me, in the hopes that it can aid you in determining the source of your error. I will bold the code that changed.

Original code:
include_once('FX/FX.php');
include_once('FX/FMErrors.php');
include_once('FX/server_data.php');
$search1=new FX($server,$webCompanionPort);
$search1->SetDBData('MyDatabase.fmp12', 'FX_Portal_Report', 'all');
$search1->AddDBParam('SalesPOno', $criteria);
$search1Result=$search1->FMFind();
if (($search1Result->code <> 0) && ($search1Result->code <> 401)) {
	echo ('FX_FMS_Error\n');
	Exit;
}
foreach($search1Result['data'] as $key=>$search1Data) {
	$theData=$search1Data['myField'][0];
	echo '<databaseData>'.$theData.'</databaseData >';
}

Modified code:
include_once('FX/FX.php');
include_once('FX/FX_Error.php');
include_once('FX/server_data.php');
$search1=new FX($server,$webCompanionPort);
$search1->SetDBData('MyDatabase.fmp12', 'FX_Portal_Report', 'all');
$search1->SetDBPassword('myPW', 'myUN');
$search1->AddDBParam('SalesPOno', $criteria);
$search1Result=$search1->FMFind();
if (is_object($search1Result))
	if (($search1Result->code <> 0) && ($search1Result->code <> 401)) {
		echo ('FX_FMS_Error\n');
		Exit;
	}
foreach($search1Result['data'] as $key=>$search1Data) {
	$theData=$search1Data['myField'][0];
	echo '<databaseData>'.$theData.'</databaseData >';
}

Things to note on the modifications:
1) not sure of the internal changes but the filename had to be changed from FMErrors.php to FX_Error.php
2) I had to add the SetDBPassword function in order to not fail. I thought this was strange because my settings in the server_data.php file always worked before the upgrade. This is also a good example of what I meant in programming styles. Other developers may have already used this function in their code and therefore didn't require changes after upgrading.
3) the additional if() statement to test for an object was a solution offered to me by someone else on this list which helped me eliminate the "Cannot use object of type FX_Error as array" error that you are also experiencing. I suppose that this error could also be triggered in the foreach() block if you omit the Exit() function in the preceding if() statement.

Hope this helps.

Leland



On Mar 19, 2014, at 3:48 PM, fx.php_list-request at mail.iviking.org wrote:

> On Mar 19, 2014, at 2:37 PM, Ness, David <dness at bondedbuilders.com> wrote:
> 
>> This is the result of the print_r($queryResult);
>> 
>> FX_Error Object ( [error_message_prefix] => [mode] => 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20140319/460fbf84/attachment-0001.html


More information about the FX.php_List mailing list