NuSoap version 0.9.5 Attempt to modify property of non-object in nusoap.php

December 1st, 2012

I am working with NuSoap and a particular WSDL file was causing the following error for me:

PHP Warning: Attempts to modify property of non-object in lib/nusoap.php on line 4694.

To fix this problem I modified line 4694 in nusoap.php from:

$this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;

To this:

$this->schemas[$ns][$ns2]->imports[$ns2][$ii]['loaded'] = true;

And that fixed the problem.  I found the solution in the NuSoap forums, but I though I would share the information as a post in the hopes it make it easier for someone else to find, and my line number was different than the one mentioned.  It looks like it is an old problem that has not been patched in the official release.

Easy HTML Form Emailer Written in PHP

February 13th, 2010

PHP Script

This easy to use script makes it easy to have an HTML form send its contents to you via email.  The PHP script is just a few lines of code.  Just customize four lines of code so that the script will send the email to the right address.  The lines of code in the easymailer.php file to modify are:

define("EMAIL","enteremail@here.com",false);
define("DESTINATION","success.htm", false);
define("SUBJECT","An email from your website.",false);
define("FROM","webmaster@yousite.com",false);

The first line configures who will receive the emailed form.  The second line determines what page the visitor will be sent to after the script has emailed you.  The third line is the determines what you will see in the subject line of the email you receive.  Line four determines who the sender will be in the email you receive.

The HTML Form

The only requires to use the PHP script is to set the form’s method attribute to post and the action attribute to ‘easymailer.php’.  See the example form below:

<form action="easymailer.php" method="post">
<input name="name" type="text" />
<input name="email" type="text" />
<input name="action" type="submit" value="Submit" />
</form>

When the visitor clicks submit the form data will be redirected to the easymailer.php script which will send the email and then redirect them to the page you configured it to.

You can download an example below just remember to change the four lines  in the easymailer.php file so it is properly customized for your needs. Then, upload easymail.php to your PHP enabled web server.

Download easy mailer script

PHP5 Singleton Design Pattern

August 12th, 2009

The singleton design pattern allows you to insure that only one instance of an object exist at one time.  It is useful tool to prevent multiple connections to a database.  The skelton looks like this:

class MyClass{
     static private $instance = false;
 
     #This prevents the user of the class from creating an
     #instance of the object
     private function __construct(){}
     #This prevents the user from making a copy of the
     #instance
     private function __clone(){}
 
     #This is how the user gets an a single instance
     #of the class
     public function getInstance(){
           #if the static instance attribute is false
           #then create the first and only instance of
           #the class
           if(!MyClass::$instance){
                MyClass::$instance = new MyClass();
           }
           return MyClass::$instance;
     }
 
     #Here you can put all of your members and attributes
     #that your class needs.

}

To get the instance of the the class you will need to invoke the getInstance method using the double-colon notation.

$myVar = MyClass::getInstance();