Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Filemaker/PHP Strangeness (Total noob here)

Featured Replies

After updating to Filemaker Server 12.4, our web portal stopped working.  I have tracked it down to a server error (22) but while troubleshooting the issue I also ran into some problems with the actual PHP itself.  I'm not sure if this is the correct place to post this, but I have a question regarding how the below PHP code is functioning.

{//There is a token, check it...
				$find=$fm->newFindCommand('CWP_Users');
				$find->addFindCriterion('request_token', $token);
				$find->addFindCriterion('request_expires', date('m/d/Y g:i:s A')."..");
				$result=$find->execute();
				$temperror='';
				// If an error is found, return a message and exit.
				if (FileMaker::isError($result)) 
					{
						$temperror=$result->getCode();
						$Data['error']='There is a problem with the request token. Database Error Code:'.$temperror;
					};
				if ($temperror==401)
					{
						$Data['error']='There is a problem with the request token. Please contact your administrator.'.date('m/d/Y g:i:s A');
						$add =& $fm->newAddCommand('CWP_LogEntries');
						$add->setField('ip', $ip);
						$add->setField('login', $login);
						$add->setField('status', 'Bad Token');
						$add->setField('action', 'Reset');
						$result = $add->execute();
						if (FileMaker::isError($result)) 
							{
								$Data['error']="Database Error Code:".$result->getCode();
							};
					}
				   elseif($temperror)
				   	{	// something went wrong with the request
				   		$Data['error']='There is a problem with the reqquest token.  Please contact Occu-Med.';
				   		$add =& $fm->newAddCommand('CWP_LogEntries');
				   		$add->setfield('ip', $ip);
				   		$add->setfield('login', $login);
				   		$add->setField('status', $Data['error']= $Data['error']="There was a problem with the request.  Please contact Occu-Med.  Database Error: ".$result->getCode() );
				   		$add->setField('action', 'Reset');
				   		$result = $add->execute();
				 	 }			
				elseif($result)
					{	// token ok
						 $records= $result->getRecords();
						 $record=$records[0];
						 $recid=$record->getRecordId();
						 $login=$record->getField('login');
						 $requestdate=$record->getField('request_date');
						 $email=$record->getField('email');
						 $login=$record->getField('login');
					}

Based upon what I know about PHP (admittedly, very little), I would expect the script print an error message to the website here:

if (FileMaker::isError($result)) 
{
$temperror=$result->getCode();
$Data['error']='There is a problem with the request token. Database Error Code:'.$temperror;
};

However, the PHP blows right through this If statement and ultimately results in a blank page being displayed.  When I added the section with the elseif ($tempError) and this ultimately results in the correct error message being displayed.  My question is why is the PHP not displaying the first if statement, when it is obviously setting the $tempError variable? (Called later in the PHP script...)

 

Thanks!

The blank page usually means there is a parse error in your code. To have php display errors for troubleshooting, put this line at the beginning of your php script:

ini_set('display_errors', '1');

Be sure to delete it or comment it out or set it to 0 before deploying it to users.

 

 

In this case, there is a parse error in this line  

$add->setField('status', $Data['error']= $Data['error']="There was a problem with the request. Please contact Occu-Med. Database Error: ".$result->getCode() );

= $Data['error']="There was a problem with the request. Please contact Occu-Med. Database Error: ".$result->getCode()  must be removed. (In other words, everything after the first ] except the closing ) and the semicolon.)

Also, if you just want to display this to the user, you actually need an echo command - setting a variable does not display it back to the user by itself...

 

So between 36 and 27 above, something like:

echo $Data['error'];

 

And the other line should probably read like:

 

$add->setField('status', $Data['error'];

 

Cheers

Webko

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.