Contact lookup via Email field
Asked Answered
C

1

11

I am using Force.com Toolkit for PHP (Version 20.0) to integrate with Salesforce.

I would like to lookup some Contact via the email field and print in on page if the condition is met. Here is the query I used:

SELECT Name, Email, npe01__HomeEmail__c, npe01__WorkEmail__c, npe01__AlternateEmail__c FROM Contact WHERE Email = "[email protected]"

In Workbench everything works fine, however, when I use the same query in PHP I get the following error:

'MALFORMED_QUERY: npe01__AlternateEmail__c FROM Contact WHERE Email="[email protected]"
ERROR at Row:1:Column:112
Bind variables only allowed in Apex code'

What would be best practice to help me solve this problem?

Thanks!

Calamine answered 18/5, 2017 at 14:15 Comment(2)
I know SOQL is weird with " have you tried just the query SELECT Name, Email, npe01__HomeEmail__c, npe01__WorkEmail__c, npe01__AlternateEmail__c FROM Contact WHERE Email = '[email protected]' ?Martin
Yes, the quotes don't matter. I even used a variable and it doesn't work.Calamine
C
5

It turns out that halfwarr was right! I used the following code to get this to work:

$donor_email = '[email protected]';
$query = 'SELECT Name, Email, npe01__HomeEmail__c, npe01__WorkEmail__c, npe01__AlternateEmail__c FROM Contact WHERE Email=\''.$donor_email.'\'';
Calamine answered 21/5, 2017 at 8:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.