Jump to content

Synergic

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Posts posted by Synergic

  1. I have a web service which i want to consume via PHP.

     

    Whenever i attempt to communicate with it it comes up with:

     

    "Server was unable to process request. --> Object reference not set to an instance of an object."

     

    Googled it and got the following:

     

    http://php.net/soap_soapclient_soapcall

     

    Apparently this code should work to fix the above problem:

     

    <?php
    
    class Test {
    public $account;
    public $password;
    }
    
    $parameters = new Test;
    $parameters -> account = $username;
    $parameters -> password = $password;
    
    try {
    $client = new SoapClient ("https://www.somewebsite.com/Serv­ ice.asmx?wsdl", array('classmap' => array('CheckUser' => 'Test')));
    $client -> CheckUser ($parameters);
    echo "Valid Credentials!";
    }
    catch (Exception $e) {
    echo "Error!<br />";
    echo $e -> getMessage ();
    }
    
    ?>
    

     

    I modified it and my version as follows:

     

    <? class Book {
    public $author = "1";
    public $title = "2";
    public $publisher= "3";
    public $loc= "4";
    }
    
    $bookC = new Book;
    
    $sc = new SoapClient("URLTOWEBSERVICE?wsdl",­ array('classmap' => array('bookC ' => "Book")));
    
    try {
    print_r($sc->getBook($bookC));
    }
    catch (Exception $e)
    {
    echo $e->getMessage();
    }
    
    WSDL as follows:
    
    
    - <s:complexType name="Book">
    - <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="author" type="s:string" />
    <s:element minOccurs="0" maxOccurs="1" name="title" type="s:string" />
    <s:element minOccurs="0" maxOccurs="1" name="publisher" type="s:string" />
    <s:element minOccurs="0" maxOccurs="1" name="loc" type="s:string" />
    </s:sequence>
    </s:complexType>
    
    

     

     

    Been stuck on it for a while, any ideas?

     

    I've also tried using nuSoap with the same result. :|

  2. 
            $months[01] = "Jan";
      	 $months[02] = "Feb";
     $months[03] = "Mar";
    
             $i = 02; // also tried "02"
             echo $months[$i];
    
    

     

    The above code has me stumped (echos nothing). Coming from a Java background I've had no such troubles substituting array indices with variables. When i change the $i (in between the brackets) with 02 it appears to work. Any ideas?

     

  3. I have a drop down menu, i also have a value so when the form is loaded i want to select the drop down menu item based on the string. I tried all combinations and i just can't get it to auto select the drop down menu item based on the string (they're EXACTLY the same) any ideas?
  4. i haven't figured why i'm getting unidentified variable with the following insert statements. i mean using values work fine but as soon as i stick a variable inside the insert clause i get unidentified variable:

    [code]

    <?php
    include_once 'DatabaseClass.php';

    class BookStoreClass extends DatabaseClass {

    var $name = 'hello';
    var $birthday = 'hello';

    function registerUser($user)
    {
    parent::connect();

    mysql_query ("INSERT INTO birthdays (name, birthday) VALUES ('$name','$birthday')");
    parent::close();
    }

    }
    ?>

    [/code]

    Notice: Undefined variable: name in

    Notice: Undefined variable: birthday in
  5. [quote author=ToonMariner link=topic=104209.msg415452#msg415452 date=1155565618]
    Don't!

    Just have a table of artist and a field for their publisher
    [/quote]

    for simplicity i have kept things in one table. i will fix the structure once i've figured this problem.
  6. Ok i've got a CD catalog in a database. I have a cd table in the cd table i have a column for the artist, song and publisher. What i want to do is list each artist under their publisher so something like


    Sony/BMG

      Artist 1
      Artist 2

    Universal

      Artist 1
      Artist 2

    I'm just having trouble approaching the problem of printing it out. How do i populate each artist under their respective publisher?
  7. [code]
    <? if (isset($_SESSION['cart']))
    {
    echo 'Array is set.';
    } ?>

    <?echo '<pre>';
      print_r( $_SESSION );
    echo '</pre>';?>
    [/code]

    result:

    [code]
    Array is set

    Array
    (
        [cart] => ShoppingCartClass Object
            (
                [items] => Array
                    (
                    )

                [totalPrice] =>
            )

    )
    [/code]

    what gives?  :-\
  8. I'm creating a simple, non-presistent shopping cart. Currently it allows a product ID and a qty. What i want is without re-writing the code below a simple way of adding a third variable such as a description. Any ideas? Since the array only accepts one associated field inside it i can't seem to figure how to add a third attribute.

    [code] <?php




    class ShoppingCart {

        var $items;
     


        function add_items($product_id, $qty, $desc)
        {
       
      $this->items[$product_id]=$qty;
     
     
     
     
     
        }

        function update_items($product_id, $qty)
        {
          if(array_key_exists($product_id, $this->items))
          {
              if($this->items[$product_id]>$qty)
              {
                $this->items[$product_id]-=($this->items[$product_id]-$qty);
              }
              if($this->items[product_id]<$qty)
              {
                $this->items[$product_id]+=abs($this->items[$product_id]-$qty);
              }
              if($qty==0)
              {
                unset($this->items[product_id]);
              }
          }
        }
     
        function remove_item($product_id)
        {
          if(array_key_exists($product_id, $this->items))
          {
              unset($this->items[$product_id]);
          }
        }

        function show_cart()
        {
          return $this->items;
        }

    }

    $cart = new ShoppingCart;

    $cart->add_items("test", "2", "3");

    //$cart->remove_item("Apples");


    $cart_items=$cart->show_cart();

    foreach($cart_items as $key=>$value)
    {
        echo "$key $value<br>";
    }






    ?>[/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.