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. 

why doesn't this php query work?? help please

Hello, can anyone help me with this?

This code is not working very well...

until the second "Try" everything works well....
but, when I get to the query it doesn't even print the "NOT REACHING THIS PRINT!", print...

can anyone help me with this please?

<?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 "Reaching this print";  
 
      $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);
}
?>
qwertyqwerty
Off the top of my head, I would guess SForce doesn't let you specify SQL as tablename.column.  Try "select Id from lead where FirstName = 'Miguel'".

Also, please take a look at http://us.php.net/manual/en/language.exceptions.php .  query() throws an exception if it fails and is caught by the catch block.  Thus, in an error your print statement won't be run.  This is very, very basic programming knowledge.
roMancerroMancer
hi there,

is this your complete program?
just guessing:

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

where do you create $sforce?
maybe it should be like this:


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


regards,
ro