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

Troy Meyers tcmeyers at troymeyers.com
Tue Nov 15 17:07:19 MST 2011


Tim, thanks. That looks good.

Is there a reason the serverError variable should be a session variable?

To disable the rest of the page, would you just do something like this?:

	if ($_SESSION['serverError'] != "0") {
		echo "Error: ".$_SESSION['serverError'];
	} else {
?>

(entire normal page code/html)

<?php } ?>


...adding the closing bracket at the end? Or is there a way to just stop page generation in its tracks just with the lines added at the top?

-Troy




Tim wrote:

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