Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

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

I would like to look up 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!

1 Answer

0 votes
by (32.1k points)

You can try the following queries:

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

For example:

$donor_email = '[email protected]';

$query = 'SELECT Name, Email, npe01__HomeEmail__c, npe01__WorkEmail__c, npe01__AlternateEmail__c FROM Contact WHERE Email=\''.$donor_email.'\'';

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...