September 18, 200817 yr We've got an Auctions table with an InternalNotes field that usually has quite a few notes in it. Each new note is separated by a line break so it's easy to read. I have a PHP script that I'm using to update the Auction record with information from eBay. When the auction ends I'm updating the notes field some new notes. In order to do that without losing all of the previous notes I'm first pulling the notes from FM into the script, then I append new notes to it and update the record with the new notes. The problem is when they get back in FileMaker all of the lines have been pushed together like 1 huge sentence. For whatever reason it's losing the line breaks. Now, in my code for the new notes I'm using chr(13) to add line breaks in the new notes that I'm including and those do work when pushed back into FM, but all of the previous notes get pushed together one long line. How can I get the previous notes to maintain their line breaks so it doesn't screw it all up when I update the record? Before I started switching everything for this client over to PHP API I was doing everything via ODBC. The same method was applied in the old ODBC scripts and I didn't have this problem. Any information on this would be greatly appreciated. Thanks! Edited September 18, 200817 yr by Guest
September 23, 200817 yr if the line breaks are present in the value that you pull from the db you could always use str_replace() to swap them out with chr(13) I've been using 'n' to add a line break and haven't had a problem.
February 6, 201114 yr I have exactly the same problem. $var = "new note" . "\r" . $record->getFieldUnencoded("notes") ; //also tried without "Unencoded" - no change $edit = $record->setField("notes", $var ); $result = $record->commit(); error_check($result); If I keep repeating this I'll get 1st attempt: new note 2nd attempt: new note new note 3rd attempt: new note new notenew note 4th attempt: new note new notenew notenew note All previous carriage returns are lost on each new update. Anyone know how to solve this? We've got an Auctions table with an InternalNotes field that usually has quite a few notes in it. Each new note is separated by a line break so it's easy to read. I have a PHP script that I'm using to update the Auction record with information from eBay. When the auction ends I'm updating the notes field some new notes. In order to do that without losing all of the previous notes I'm first pulling the notes from FM into the script, then I append new notes to it and update the record with the new notes. The problem is when they get back in FileMaker all of the lines have been pushed together like 1 huge sentence. For whatever reason it's losing the line breaks. Now, in my code for the new notes I'm using chr(13) to add line breaks in the new notes that I'm including and those do work when pushed back into FM, but all of the previous notes get pushed together one long line. How can I get the previous notes to maintain their line breaks so it doesn't screw it all up when I update the record? Before I started switching everything for this client over to PHP API I was doing everything via ODBC. The same method was applied in the old ODBC scripts and I didn't have this problem. Any information on this would be greatly appreciated. Thanks!
February 9, 201114 yr Have you guys tried using \n or \n\r instead of \r? Maybe try: str_replace(array("\n","\n\r","\r"),"\r","new note\r".$record->getFieldUnencoded("notes")); Failing that, try swapping the \r in the replace statement out for any of the alternatives.
February 9, 201114 yr Have you guys tried using \n or \n\r instead of \r? Maybe try: str_replace(array("\n","\n\r","\r"),"\r","new note\r".$record->getFieldUnencoded("notes")); Failing that, try swapping the \r in the replace statement out for any of the alternatives. wow, your code works. By the way, writing \n to FileMaker does not work, and \n\r works just as well (or not well) as \r I guess what is happening here is that you need to write \r to FileMaker for you to see the line break in FileMaker, BUT when you read that field back into php, it substitutes the \r for \n ( for some unknown reason). You need to substitute them back when writing, or you lose your line breaks. Thanks for your help!
Create an account or sign in to comment