May 19, 200916 yr 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
May 19, 200916 yr 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?
May 20, 200916 yr 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
May 21, 200916 yr 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/
May 21, 200916 yr 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
July 19, 200916 yr 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!!
July 19, 200916 yr Use nl2br() instead of str_replace() to replace natural line breaks with It will catch all of the different OS idiosyncrasies
July 21, 200916 yr 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