smit1626
You had a few small mistakes in your code, but that may have been done when you posted it. I revamped a little, try this code and see if it works for you. I tested it on my localhost and it works fine against my salesforce developer organization or instance:
PHP Code:
<?php
ini_set("soap.wsdl_cache_enabled","0");
$username = 'me@email.com';
$password = 'password';
$date = date("m/d/y");
require_once ('./soapclient/SforcePartnerClient.php');
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection("./soapclient/partner.wsdl.xml");
$mylogin = $mySforceConnection->login($username,$password);
$email_address = "bob@smith.com";
$redirect_file = 'test file';
try
{
if ($mylogin)
{
$query = "SELECT Id, Description,FirstName, LastName from Contact where Email='$email_address'";
$response = $mySforceConnection->query($query);
$queryResult = new QueryResult($response);
foreach ($queryResult->records as $record)
{
echo '<pre>' . print_r($record,true) . '</pre>';
$sObjectContact = new sObject();
$sObjectContact->type = 'Contact';
$sObjectContact->Id = $record->Id;
$sObjectContact->fields = array('Description' => $record->fields->Description . ';Document download from website:' . $redirect_file . ' on ' . $date);
print_r($sObjectContact);
$result = $mySforceConnection->update(array($sObjectContact));
// print_r($result);
if ($result->success)
{
echo "good";
}
else
{
echo "bad";
}
}
}
else
{
echo "crap, something is wrong";
}
}
catch (exception $e)
{
echo $mySforceConnection->getLastRequest();
echo $mySforceConnection->getLastRequestHeaders();
echo '<pre>' . print_r($e,true) . '</pre>';
}
?>
I had to set some local variables to test your code. If you compare the two scripts next to each other, you will see a few small differences, but it was not that much
Hope that helps and you should register here if you are going to be working on salesforce applications
let me know if you have any other questions
~Mike