0
votes

I am using the PHP Toolkit (v20) with the Enterprise WSDL to access my Salesforce objects and records in my webapp.

I successfully got everything working on my localhost.

When I uploaded the script to my webhost (inmotion), the create function simply does not work. It does not show any errors or warnings (although I have set error reporting to E_ALL), but execution of the script simply stops when it encounters the create function.

However, running a query using the query function or something like getting the server timestamp works fine.

Again, it works fine on my localhost, so I dont think its a code problem, but for the life of me I cannot figure out the problem, as no errors/warnings are displayed nor exceptions thrown.

I should clarify that although in this example I am trying to insert into my custom object, I have tried to insert into a standard Account or Contact object as well and it has not made any difference.

It will be great if somebody can guide me on how I can go about trying to troubleshoot the problem.

Thanks.

Code is as follows:

<html>
<head></head>
<body>
<?php
    ini_set("soap.wsdl_cache_enabled", "0");
    define("USERNAME", "myusername");
    define("PASSWORD", "mypassword");
    define("SECURITY_TOKEN", "mysecuritytoken");

    require_once ('soapclient/SforceEnterpriseClient.php');

    try {
            $sflink = new SforceEnterpriseClient();
            $sflink->createConnection("soapclient/auv.wsdl.xml",null,array('trace'=>true));
            //$sflink->createConnection("soapclient/auv.wsdl.xml");
            $sflink->login(USERNAME, PASSWORD.SECURITY_TOKEN);

            // Test to get the server timestamp - Works fine.   
            echo "Getting Timestamp<br>";
            $resp = $sflink->getServerTimestamp();
            print_r($resp);
            echo "<br>";

            // Test to query the server - Works fine.
            $query = "SELECT Id, AccountId, FirstName, LastName FROM Contact WHERE Email = '[email protected]'";
            $response = $sflink->query($query);

            echo "Select result is: <br>";
            print_r($response);
            echo "<br>";

            // Insert into UVSI Search Object (My custom object) - Does not work
            $sObject = new stdclass();
            $sObject->Account__c = "00190000006yxUrAAI";
            $sObject->Contact__c = "00390000005ZYLcAAO";
            $sObject->Application__c = "AAP";
            $sObject->Flow__c = 66;
            $sObject->Flow_Unit__c = "m3-hr";
            $sObject->Dose__c = 33;
            $sObject->UVT__c = 99; 
            echo "Attempting creation<br>";
            $createResponse = $sflink->create(array($sObject), 'UVSI_Search__c');
            echo "This line never prints.<br/>";

        } catch (Exception $e) {
            echo "In error condition<br>";
            echo $sflink->getLastRequest();
            echo $e->faultstring;
            exit();
        }

?>
</body>
</html>
1
did you try error_reporting(E_ALL); AND ini_set('display_errors', true); and all other ini_set things? -> bit.ly/15C3oVX - Daniel W.
Thanks. Yes I did. I had put them in the php.ini file, but just to check I also just included them in the php code but to no avail. - ankGT
Could it be that whatever hosting provider you're using is blocking the outbound connection to Salesforce.com? I once had this type of issue with PHP on my GoDaddy account. - amrcn_werewolf

1 Answers

0
votes

After breaking my head over this for 3 days, I finally found a solution. I changed the PHP version for my site from 5.2 to 5.3 and the problem just went away.

I still dont know why it did not work, but this is the solution in case anybody else has a similar problem.