function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
S2S CRM AdminS2S CRM Admin 

Select statement works in Salesforce Dev console but not when run through my php file

I need to creat a select statement that will pull the first name, last name, and title of all the people who have signed up for a specific event in salesforce. To do this I built the following statement:
SELECT Contact.FirstName, Contact.LastName, Contact.Title FROM CampaignMember WHERE CampaignId='701i00000010q96'

This statement works just fine when I put the statement into my php file and run it I get the following error statements:
PHP Notice:  Undefined variable: record in C:\Sites\s2s\htdocs\tech_demo\salesForce\soapclient\SforceBaseClient.php on line 973
PHP Notice:  Trying to get property of non-object in C:\Sites\s2s\htdocs\tech_demo\test.php on line 34
PHP Notice:  Trying to get property of non-object in C:\Sites\s2s\htdocs\tech_demo\test.php on line 34
PHP Notice:  Trying to get property of non-object in C:\Sites\s2s\htdocs\tech_demo\test.php on line 35
PHP Notice:  Trying to get property of non-object in C:\Sites\s2s\htdocs\tech_demo\test.php on line 35
PHP Notice:  Trying to get property of non-object in C:\Sites\s2s\htdocs\tech_demo\test.php on line 36
PHP Notice:  Trying to get property of non-object in C:\Sites\s2s\htdocs\tech_demo\test.php on line 36

Line 34, 35, and 36 are where I print the results to the screen. This leads me to believe that the root cause of the problem is the first error, the only problem is I do not understand why I am getting that error.
Manish BhatiManish Bhati
Hi S2S CRM Admin,

Seems like the query should work fine.
But, i can't see the variable 'record in' nor I know where you are using it.
So, you have to keep below thing in mind:-
- The return type of this SOQL statement is a List of type SObject. Try to capture the result of this statement properly.

See if you are doing something like:-
                $query = "Your SOQL Query"
                $result = $mySforceConnection->query($query);
                   if ($result->size > 0) {
                     $sObject1 = new SObject($result->records[0]);
                     print_r($sObject1);
                    }