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.

Featured Replies

I followed the example from FX folder, create a list.php, detail.php, and apply to my database. Everything works fine.

I got stuck when I try to update a record. there is no error message, but the record cannot get updated. Here is my detail.php

<?php

require_once ("FX.php");

require_once("server_data.php");

$Query = new FX($serverIP, $webCompanionPort);

$Query->SetDBData("MyDB.fp5", "Form view");

$currentRecord = $_GET['ID'];

$Query->AddDBParam('-recid', $_GET['ID']);

$result = $Query->FMFind();

$currentKey = key($result['data']);

?>

<html>

<body bgcolor="#FFFFFF">

<form name="detail" action="edit.php?" method=POST>

<p>Injury Date:

<input name="Injury_Date" type="text" id="Injury_Date" value="<?php echo $result['data'][$currentKey]['Injury_Date'][0]; ?>" >

</p>

<p>Test Field:

<input name="test" type="text" value="<?php echo $result['data'][$currentKey]['test'][0]; ?>">

<input type="hidden" name="ID" value="<?php echo $currentRecord;?>">

<input type="submit" name="Submit" value="Update">

</p>

</form>

</html>

and here is my edit.php

<?php

require_once ("FX.php");

require_once("server_data.php");

$recordID = $_POST['ID'];

$Query = new FX($serverIP, $webCompanionPort);

$Query->SetDBData("MyDB.fp5", "Form view");

$Query->AddDBParam('-recid', $recordID);

if ($_POST['Submit']){

foreach ( $_POST as $key => $value)

{

$Query->AddDBParam($key, $value);

//$Query->AddDBParam('test', $_POST['test']);

//$Query->AddDBParam('Injury_Date', $_POST['Injury_Date']);

}

}

$returnData = $Query->FMEdit();

?>

As you can see in edit.php, if I use:

$Query->AddDBParam('test', $_POST['test']);

$Query->AddDBParam('Injury_Date', $_POST['Injury_Date']);

instead of the foreach()function, the record WILL get updated. So seems is the foreach() causes problem. (My php version: 4.3.6)

Can someone please help me? Thanks!

Hi, new comer! I'm a PHP newbie newer than you, but the following line looks suspect to me...

<input type="hidden" name="ID" value="<?php echo $currentRecord;?>">

At first I thought it was your call to $recordID = $_POST['ID']; since I didn't think ID was in the POST, but then I saw you had did have ID in the post but it didn't look right. I don't know FX but maybe it should be $CurrentRecID or $currentRecordID or something?

In CDML, I used to see that a lot w/folks... missing or malformed [FMP-CurrentRecID] statements which are needed for any edit. I could be way off, though, since I'm in the dark but that's my newbie guess!

--ST

  • Author

Steve, I add one line to print $recordID, and output is correct. also, if the pointer points to a wrong record, the following statements should not work either.

$Query->AddDBParam('test', $_POST['test']);

$Query->AddDBParam('Injury_Date', $_POST['Injury_Date']);

But thank you very much for looking into my code. Really glad I'm not alone in dark!

Well, if no one else offers any good ideas... here are some more gooses you chase if you like...

- initialization of variables in functions

I think php changed the requirement for variables since FX was written; try pre-initializing variables in your functions before the functions try to use them. $myfield = ""; or using VAR.

- foreach

"PHP 4 (not PHP 3) includes a foreach construct, much like Perl and some other languages. This simply gives an easy way to iterate over arrays. foreach works only on arrays, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable..."

http://us4.php.net/foreach

- layout

I don't know if FX has layout references, but sometimes I'd refer to fields that were not on my web layout and no errors would be generated but data would be blank. If no layout was specified, FMP uses some kind of Layout.0 hidden layout that has all fields or something.

That's all I got... anyone else?

--ST

Create an account or sign in to comment

Important Information

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

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.