AnsweredAssumed Answered

Unable to connect to FileMaker database with PHP

Question asked by neeeeet on Aug 15, 2016
Latest reply on Sep 9, 2016 by chiweez

Hi all,

 

I have been trying to establish a connection between FileMaker 12 and the PHP API but the script keeps returning "Not Connected", and the message "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."

 

I have double-checked to make sure the spellings of the username and password are correct, and Full Access has already been administered to the user for the FMPHP Privilege.

 

This is my script:

 

//======================================================================

  //CONNECT TO DATABASE AND CHECKING CONNECTION THROUGH A FUNCTION.

//======================================================================

 

 

  //Populating the arguements

  $booIsFMDBConnected = IsFMDBConnected(true, 'database', 'hostsite', 'username', 'password');

 

 

  If($booIsFMDBConnected){

  //===================

  //Database is Connected

  //===================

  echo "Connected";

  } else {

  //======================

  //Database is Not Connected

  //======================

  echo " Not Connected";

  }

 

 

  function IsFMDBConnected($booVerbose, $strDatabase, $strHostspec, $strUsername, $strPassword) {

  //==========

  //Initialisation.

  //==========

 

  $fm =& new FileMaker($strDatabase, $strHostspec);

  //$fm->setProperty('database', $strDatabase);

  //$fm->setProperty('hostspec', $strHostspec);

  $fm->setProperty('username', $strUsername);

  $fm->setProperty('password', $strPassword);

  $connected = $fm->listLayouts();

 

 

  //==================

  //Return the Result.

  //==================

  If(FileMaker::isError($connected)){

  //======

  //Error.

  //======

  $booIsFMDBConnected = false;

 

  If($booVerbose) {

  //=============

  //Verbose Mode.

  //=============

  echo "<br>" . $connected->message . "<br>";

  }

 

  } else {

  //=========

  //No Error.

  //=========

  $booIsFMDBConnected = true;

  }

 

  return $booIsFMDBConnected;

 

  }

 

 

The script seems to be recognising the hostspec but not the database, username or password. I don't know why this is so. Does anyone know how to get the connection to work? Any help would be greatly appreciated, thank you.

Outcomes