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

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

Recommended Posts

  • Newbies
Posted

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

Posted

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?

  • Newbies
Posted

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

Posted

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/

Posted

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...
Posted

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!!

Posted

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

This topic is 5602 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.