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
M.M. 

sforce php query

Hello everyone....

I'm trying to query the salesforce database... I can successfuly login into the salesforce, but there seems to be something wrong with the query... can anybody help me here?

I'm ussing a login code, and then this...

try
{
    $result = $sforce->query(array("queryString" => "select Id from Lead where Lead.FirstName='Miguel'"));
    print_r($result);
    print "I'm not reaching this print";
} catch (Exception $e)
{
    print_r($e);
}


what happens is that it doesn't print the "I'm not reaching this print"... can anyone help me with this?
thank you

M.
ClaiborneClaiborne

The query string should not be an array.

Try this.

$query =  "select Id from Lead where Lead.FirstName='Miguel'";

$result = $sforce->query($query);

M.M.
Thank you, but still not working....

here is the whole code:

<?php
 
require_once ('C:\Program Files\PHP\ext\soapclient\SforcePartnerClient.php');

try
{
    $mySforceConnection = new SforcePartnerClient();
    $mySoapClient = $mySforceConnection->createConnection("partner.wsdl.xml");
    $mylogin = $mySforceConnection->login("admin@*****.com", "******");
 
      print "XIS2!";  
 
      $userResult = $mylogin->userInfo;
      print $userResult->userFullName.', your session id is '.$mylogin->sessionId;

}
catch (Exception $e)
{
  echo $e->faultstring;
}

try
{
   // $result = $sforce->query(array("queryString" => "select Id, FirstName, LastName from Lead where Lead.FirstName='Miguel'"));
   // print_r($result);
   $query =  "select Id from Lead where Lead.FirstName='Miguel'";
   $result = $sforce->query($query);
   print_r($result);
   print "NOT REACHING THIS PRINT!";

} catch (Exception $e)
{
    print_r($e);
}
?>

HarmpieHarmpie
Just taking a quick shot at it. Could you try editing your query to :
$query =  "select Id from Lead where FirstName='Miguel'";

 
BDSjimBDSjim
Look where $sforce is defined - it doesn't have scope where you're trying to use it inside the second try block.