5

I am connecting to FileMaker Pro 11 Server with a ODBC Connection. I am importing some information from the eBay API.

When I recieve the address from ebay, it comes in two fields address1 and address2. In the FileMaker database we just have one field for address. I am trying to separate the two addresses with a line break or carriage return with PHP but it never seems to work.

I would try to insert:

"$var1\n$var2"

and FileMaker will read the \n as normal text. Same goes for \r. I have also tried setting the string with:

<<<EOF 

with no success either. I also tried the pie symbol that I read works for line breaks but it does not work in this manner.

So basically.. how can I insert a line break that filemaker will understand with php pdo and odbc?

Ghassan Idriss
  • 2,120
  • 20
  • 16
  • 1
    That's an uncommon database, so you won't find many experts even on Stackoverflow. Anyway which code did you use? If you used an escaping function (or even the wrong one?) then this might just be how it ends up in the DB. Otherwise try PDO bound parameters `$s = $pdo->prepare("INSERT INTO tbl (x) VALUES (?)"); $s->execute(array("var1 \n var2"));` – mario Apr 12 '11 at 22:29

4 Answers4

2

I did some testing, and found that even if I did something like $var1 . ord( 10 ) . $var2 it wasn't working correctly. I did double-check and the carriage return in a field when typed in from within the FileMaker client is ASCII char 10 (\n). So here's how I solved it.

I edited the record to insert '12<br>34'. Then I set the field definition within FileMaker for the field I was setting to auto-enter a calculation. My field was called TestField, so my calculation turned out to be Substitute( TestField; "<br>"; ¶ ). Make sure you uncheck the Do not replace existing value checkbox. Once I did that, editing the field from PHP using '12<br>34' as the string put in a carriage return between the 12 and the 34.

Chuck
  • 4,662
  • 2
  • 33
  • 55
  • That worked. I am not a big fan of filemaker but my work uses it so I have to deal with it. – Ghassan Idriss Apr 13 '11 at 18:39
  • You know, I just thought of something else. When I search email addresses in FileMaker from PHP, I have to escape the @ symbol because it has special meaning for FileMaker searches. The escape sequence is a backslash. Perhaps two backslashes for the carriage return would work, i.e., `\\n`. Haven't tried it, but that might be the *correct* solution. – Chuck Apr 19 '11 at 05:20
  • 1
    Coming back to this questions, using normal \n works fine, I had a bug in my code, which before persisting to the database used single quotes instead of double quotes which removed that new line characters. – Ghassan Idriss Feb 02 '13 at 20:18
1

The break has to be in it's own double quote like this:

$var1 . "\n" . $var2

or:

'var1' . "\n" . 'var2'
1

Ran into this issue with Filemaker and Java JDBC today. Here's the solution which may of help to others.

Character ch = new Character('\n');                    
String dataForFM = "Field Data Here" + ch.toString() + "More Field Data Here";
Ashley Swatton
  • 2,104
  • 1
  • 18
  • 27
1

Ran across this page on google when having the same problem. Didn't want to try using the auto-enter cal option so got it going with php alone...

    $var1 . char( 13 ) . $var2  

Also when pulling a value out of FileMaker field that has carriage returns you need to be careful when you put it into a variable and back into FileMaker. For example:

To pull it into a php variable:

    $variable = nl2br($record->getField("field1"));

and to put it back into FileMaker:

    $record->setField('field1',str_replace('<br />',chr(13),$variable));

Regards

bsg
  • 11
  • 1