[FX.php List] Best way to disable FX-based pages, with a nice message?

Tim 'Webko' Booth tim at nicheit.com.au
Tue Nov 15 16:52:50 MST 2011


On 16/11/2011, at 10:47 AM, Troy Meyers wrote:

> Virtually every page in our site is dependent on FX.php and  
> FileMaker. I guess I'm late in learning the best way to handle the  
> situation where (for whatever reason, including on purpose) the WPE  
> is off or not working. I suppose it's good that FileMaker Server is  
> almost always "up" for us.
>
> I'm doing a bunch of FileMaker merging work (combining individual  
> database files into one) and I'm at the point were this one  
> particular merge would best be done without allowing anyone web  
> access during the process of "rewiring" what were external file  
> references.
>
> Is there an easy and clean way, just by adding a little code to the  
> top of each PHP page, to detect when the WPE is turned off, and put  
> up a friendly message of explanation?
>
> I _know_ this has been discussed, but I'll be darned if I can think  
> of the right keywords to find it in the archives.

I use something like:

	//Simple server tests
	$_SESSION['serverError'] = ""; // reset server error
	//Check if Port 80 works at all
	if( !fsockopen ($dbHost, 80, $errno, $errstr, 2) )	{
		$_SESSION['serverError'] = "Server not up";
	} else {
		//Check if a findany to an available table works
		$pageObj=new FX($dbHost,$port,$dbType,$conType);
		$pageObj -> setDBPassword($dbPass,$dbUser);
		$pageObj -> setDBData($dbName,'VALID LAYOUT NAME', 'all');
		$pageData = $pageObj -> FMFindAny();
		$_SESSION['serverError'] = $pageData['errorCode'];
	}
	if ($_SESSION['serverError'] != "0") {
		echo "Error: ".$_SESSION['serverError'];
	}

If it's the database not available, that's probably an 802 you'll get  
back from the second test


More information about the FX.php_List mailing list