September 16, 201312 yr 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!
September 17, 201312 yr 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.)
September 19, 201312 yr 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