title: Attempt to assign property of non-object error
body: <p>I am getting this error and i can't see what i am doing wrong. I have done the same thing with other objects from other classes which are built in the exact same way and i can't see why i am getting this error now.</p>
  
  <p>The code in which i create the object is this one:</p>
  
  <pre><code>$consulta2 = "SELECT * FROM TiposDireccion WHERE Cliente_CIF='$cif' and Direccion_Direccion='$direccion' and Direccion_CP=$cp ";
                  echo($consulta2."&lt;/br&gt;");
                  if ($resultado2 = $conexion-&gt;query($consulta2)){
                      while($fila2 = $resultado2-&gt;fetch_object()){
                          $tipodireccion78=$fila2-&gt;TipoDireccion_Tipo;
                          //we see here that the select is returning a correct string with a correct value
                          echo($tipodireccion78);
                          //we try to instantiate and it fails =(
                          $unTipoDireccion=TipoDireccion::constructor1($tipodireccion78); 
  </code></pre>
  
  <p>This is the class TipoDireccion:</p>
  
  <pre><code>&lt;?php
  
  class TipoDireccion{
  
  private $tipo;
  private $descripcion;
  
  //Construct auxiliar
  function __construct() {
  
  }
  
  //Constructor 1 : completo
  function constructor1($tipo) {
  
       $tipoDireccion = new TipoDireccion();
  
       $tipoDireccion-&gt;tipo = $tipo;
  
       return $tipoDireccion;
  }
  
  function ponTipo($tipo) {
      $this-&gt;tipo = $tipo;
   }
  
  function devuelveTipo() {
       return $this-&gt;tipo;
   }
  
  function ponDescripcion($descripcion) {
       $this-&gt;descripcion = $descripcion;
   }
  
  function devuelveDescripcion() {
       return $this-&gt;descripcion;
  }   
  
  }
  ?&gt;
  </code></pre>
  
  <p>Thank you a lot in advance!</p>