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

  • Newbies

Hi,

I have a problem with creating new records. After this command:

$addCommand->setField('FieldName',$myRecord->getField('FieldName2', 0));

there are no line breakes in the field 'FieldName'.

'FieldName2' contents some line breaks and I wont to have them in the 'FieldName'.

Am I doing something wrong?

If someone could help me, I would be very greatfull.

Rafal

if it's not a typo in your post, the semi-colon between $myRecord-> and getField(

is a PHP syntax error

If that's not the problem what error message is php and/or the Filemaker object throwing?

  • Author
  • Newbies

it was a typo. the syntax is ok.

no error message is throwing by php and/or the Filemaker.

I've tried to do it with the nl2br function

$addCommand->setField('FieldName',nl2br($myRecord->getField('FieldName2')));

and the result look like this:

some text,

some text

That's what nl2br() does. It's generally used for printing content to the screen, because HTML ignores most white-space including carriage returns.

Exactly what problem are you having?

Is the record created?

If yes then does `FieldName` contain a value?

If yes how does that value differ from what you expected?

You said the were no Filemaker errors are you running the following code to check for them?




$result = $addCommand->execute();

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

	echo "Error: (" . $result->getCode() . ") " . $result->getMessage(); 

}

Lastly does `FieldName2` contain any non latin characters?

is so try this

http://fmforums.com/forum/showtopic.php?tid/201486/post/318728/

It's tough to tell exactly what you are trying to do from a little snippet of code, but I can tell you that working with line breaks with FileMaker and PHP is a little tricky.

When you have a FileMaker field that contains line breaks and your pull that data with PHP, it shows up on the PHP side as n or the new line character.

If you want to use PHP to set a FileMaker field with line breaks in it (e.g. a checkbox field is the most common example) then you have to use the r character sequence.

Bear in mind that I am a mac/linux dude, so YMMV if Windows is involved. I just wrote an article for Advisor that touches on this topic, but I am not sure when it will be released.

HTH,

j

  • 1 month later...

I'm struggling with exactly this but replacing n doesn't seem to be working for me.

I'm pulling a text field that includes line breaks out of FileMaker via getField(). I've also tried getFieldUnencoded() and I seem to get the same result.

I lose all of my line breaks when I pull the data and echo it to a web page. I tried using str_replace() to replace n with

but that isn't working.

Any info on how to get this to work would be greatly appreciated. Thanks!!

Ah, on Windows I had to replace chr(10) with chr(13).

Use nl2br() instead of str_replace() to replace natural line breaks with

It will catch all of the different OS idiosyncrasies

Hi Rafal

Getting line breaks from an HTML text area into FMP fields can be affected by the charset of the page.

Check that your charset is UTF-8 in the line within the html

element, like:

You can also try adding UTF-8 directly to your form, like:

nl2br() is the PHP function for getting line breaks that exist in FMP fields to display as separate lines in HTML

"nl2br" stands for NewLine character (e.g. n or r) TO line BReak (or

tag)

HTH,

-Joel

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.