PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,369 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,439 people online right now. Registration is fast and FREE... Join Now!




PHP examples

 

PHP examples

gilbertsavier

2 Jul, 2009 - 12:50 AM
Post #1

New D.I.C Head
*

Joined: 2 Jul, 2009
Posts: 15


My Contributions
Hi,
These are working for me, feel free to use them at your own risk
CODE

class MSSoapClient extends SoapClient {
    private $namespace;
    function __doRequest($request, $location, $action, $version) {
        

        $request = preg_replace('/<ns1:(\w+)/', '<$1 xmlns="'.$this->namespace.'"', $request, 1);
        $request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
        $request = str_replace(array('/ns1:', 'xmlns:ns1="'.$this->namespace.'"'), array('/', ''), $request);
        
        // parent call
        return parent::__doRequest($request, $location, $action, $version);
    }
    function setNamespace($sNamespace)
    {
        $this->namespace=$sNamespace;
    }
    
}  

To make a new customer - I'm only you can extend the function to add other details to the record.

function newKashflowCustomer($soapClient,$idAccount,$name,$address,$town,$postcode,$country,$email)
{
    //returns customer id if ok else 0
    
    $today = date("Y-m-d",mktime());
    
    $customerArray = array(
        "CustomerID"=>"",
        "Code"=>"",
        "Name"=>"$name",
        "Contact"=>"",
        "Telephone"=>"",
        "Mobile"=>"",
        "Fax"=>"",
        "Email"=>"$email",
        "Address1"=>"$address",
        "Address2"=>"",
        "Address3"=>"$town",
        "Address4"=>"$country",
        "Postcode"=>"$postcode",
        "Website"=>"",
        "EC"=>"0",
        "Notes"=>"",
        "Source"=>"",
        "Discount"=>"0",
        "ShowDiscount"=>"0",
        "PaymentTerms"=>"0",
        "ExtraText1"=>"1",
        "ExtraText2"=>"1",
        "CheckBox1"=>"1",
        "CheckBox2"=>"1",
        "Created"=>"$today",
        "Updated"=>"$today");
    
    $args = array ("UserName"=>"your username here", "Password"=>"your password here","custr"=>$customerArray);
    $oResponse = $soapClient->InsertCustomer($args);
    //handle any errors
    if($oResponse->Status != "OK")
    {
        echo $oResponse->StatusDetail;
        $return = 0;

    }
    else
    {
        $id = $oResponse->InsertCustomerResult;
        
        $return = $id;
        
    }
    return $return;
}


** Edit ** code.gif

User is offlineProfile CardPM
+Quote Post


no2pencil

RE: PHP Examples

2 Jul, 2009 - 12:51 AM
Post #2

i R L33t Skiddie, k?
Group Icon

Joined: 10 May, 2007
Posts: 13,218



Thanked: 289 times
Dream Kudos: 2875
Expert In: Goofing Off

My Contributions
What is this code, what does it do?
User is online!Profile CardPM
+Quote Post

noorahmad

RE: PHP Examples

2 Jul, 2009 - 03:35 AM
Post #3

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,018



Thanked: 125 times
Dream Kudos: 1350
My Contributions
Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
  • Post the code you're having problems with
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

User is online!Profile CardPM
+Quote Post

Closed TopicStart new topic

Time is now: 11/7/09 09:02PM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month