Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5717 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

Hello everyone,

PHP gives the following error when trying to connect to FM and perform a search:

Communication Error: (22) The requested URL returned error: 404 - This can be due to an invalid username or password, or if the FMPHP privilege is not enabled for that user.(22)

The php code which gives this error is:

require_once('FileMaker.php');

$database = "DatabaseName";

$hostname = "192.168.1.2";

$username = "****";

$password = "****";

$connection =& new FileMaker($database, $hostname, $username, $password);

$cmd =& $connection->newFindCommand('INVOICE');

$cmd->addFindCriterion('_InvoiceID', '1003');

$result = $cmd->execute();

if (FileMaker::isError($result)) {

if ($result->code != 401) {

echo 'Error: ' . $result->message . '(' . $result->code . ')';

die();

}

else $notFound = true;

}

Let me give you some info on the server:

-Windows 2003 Server R2 Standard x64 Edition

-FM Server 10

-FM Pro 10

-PHP works, I can run phpinfo() and see all the details.

-I have a database installed, I can connect to it usinf FM Pro and browse/edit all the layouts and records, it works.

-I have created a php user account, I can use this accoutn to log in FM Pro and it works.

-I have check the username or password so many times I almost went blind.

-The FMPHP privilege is enabled.

-The PHP column for my database has a green tick.

Finally, I have searched the web for hours, any help would be much much appreciated.

If you need any other piece of information about the server state/config just ask.

Posted (edited)

The 404 (file not found error) is tricky. First attempt some more basic calls to the XML feed. These will give you a better idea of what is and isn't working


require("FileMaker.php");

$fm = new FileMaker("myDB", "fmserver.host.com", "username","password");



$dbs = $fm->listDatabases(); /*will work regardless of validity of login */

if (FileMaker::isError($dbs)) { /*can't connect to server*/

	echo $dbs->getMessage();

	exit;

}

echo"
";
print_r($dbs); echo ""; $layouts = $fm->listLayouts(); if (FileMaker::isError($layouts)) { /*can't connect to database generally returns a 401 for invalid or unauthorized login*/ echo $layouts->getMessage(); exit; } echo"
";
print_r($layouts); echo ""; $page = $fm->getLayout("myLayout"); if (FileMaker::isError($page)) { /*can't find layout generally returns "Layout is Missing"*/ echo $page->getMessage(); exit; } echo"
";
print_r($page->listFields()); echo "";

edited to add:

You didn't specifically state that you'd enabled access via PHP Web Publishing to the Privilege Set assigned to the "php user account". If you haven't the listLayouts() step in the code above will return a 401

Edited by Guest
  • Newbies
Posted

Hi Baloo,

many thanks for that.

When I run that code I get the following message:

Did not receive an XML document from the server.

Is that message helpful?

Here is a screenshot:

esto2.png

esto.png

But then again in the FM Server -> Configuration -> web publishing -> XML box is ticked, so its ON.

And still it clearly says in there that even if it is off it will not stop the php api from working.

How shall I proceed? Thanks,

Posted

The screenshots aren't showing up (it's most likely the firewall I'm behind) so I'll check back later. If you're getting that error when you make the listDatabases() call. It's most likely a problem with IIS permissions, and I'm afraid I can't help you much there.

What do you get when you surf to

http:// your Filmaker Host /fmi/xml/fmresultset.xml

This topic is 5717 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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