Because the sql statement tells me (Capturable fatal error: Accounts object class could not be converted to string)?

0

I am looking to insert the time () date; but before comparing it inside the sql but this throws me this error:

Capturable fatal error: Accounts object class could not be converted to string in C: \ xampp \ htdocs \ www \ WEB Studios \ Studied Codes \ Prinick \ Prinick04 \ PHP Advanced \ core \ models \ class.Cuentas.php on line 23

From class.Access

public function Login(){
        try {
            if (!empty($_POST['user']) and !empty($_POST['pass']) and !empty($_POST['session'])) {
                $db = new Conexion();
                $this->user = $db->real_escape_string($_POST['user']);
                $this->pass = $this->Encrypt($_POST['pass']);

                $sql = $db->query("SELECT * FROM user WHERE user='$this->user' AND pass='$this->pass'; ");

                if ($db->rows($sql) > 0) {
                    $datos = $db->recorrer($sql);
                    $_SESSION['id'] = $datos['id'];
                    $_SESSION['user'] = $datos['user'];
                    $_SESSION['email'] = $datos['email'];
                    $_SESSION['fecha'] = $datos['fecha'];
                    $_SESSION['nombre'] = $datos['nombre'];
                    $_SESSION['apellido'] = $datos['apellido'];
                    $_SESSION['cambio'] = $datos['cambio'];


                    if ($_POST['session'] == true ) {
                        ini_set('session.cookie_lifetime',time() + (60*60*24*2) );
                    }
                    echo 1;
                }else{
                    throw new Exception(2);
                }
                $db->liberar($sql);
                $db->close();
                }else{
                    throw new Exception("Error : Datos Vacios");
                }
        }catch (Exception $login) {
            echo $login->getMessage();
        }
    }//function Login

From classCuentas.php

  <?php
      class Cuentas{

        private $user;
        private $email;
        private $fecha;
        private $id;
        private $nombres;
        private $apellidos;

        public function EditUser(){
          if (!empty($_POST['user']) and !empty($_POST['email'])) {

                  $db = new Conexion();
                  $this->user = $db->real_escape_string($_POST['user']);
                  $this->email = $db->real_escape_string($_POST['email']);
                  $id = $_SESSION['id'];

                    // Control de Error para el Usuario
                  if (strtolower($this->user) != strtolower($_SESSION['user']) ){
                    $time = time();
                  //  --------------------------------------------------------
                    //Hay quue revisar las sql1 y 2
                    $sql2 = $db->query("SELECT user FROM user WHERE user='$this->user' AND id <> '$this->$id'; ");

                    $sql = $db->query("SELECT cambio FROM user WHERE cambio > '$time' AND id='$this->$id'; ");

----------------------------------------------------------

                    if ($db->rows($sql) > 0) {
                        $db->liberar($sql,$sql2);
                        $db->close();
                        header('Location: ?view=cuenta&error=5');
                        exit;
                    }

                    if ($db->rows($sql2) > 0) {
                      $db->liberar($sql,$sql2);
                      $db->close();
                      header('Location: ?view=cuenta&error=2');
                      exit;
                    }
                      $c_cambio = 1;
                  }

                  //Control de Error para el Email
                  if (strtolower($this->email) != strtolower($_SESSION['email']) ) {

                    $sql = $db->query("SELECT email FROM user WHERE email='$this->email' AND id <> '$this->$id' ;");
                    if ($db->rows($sql) > 0) {
                      $db->liberar($sql);
                      $db->close();
                      header('Location: ?view=cuenta&error=3');
                      exit;
                    }

                  }

                  //Control de Error para la Fecha
                  $this->fecha = $db->real_escape_string($_POST['fecha']);
                  $explode = explode('-',$this->fecha);

                  if ( !($explode[0] >= 1 and $explode[0] <= 31) or
                     !($explode[1] >= 1 and $explode[1] <= 12) or
                     !($explode[2] >= 1900 and $explode[2] <= 3000) ) {
                    header('Location: ?view=cuenta&error=4');
                    exit;
                   } //Se necesita compartibilidad con el calendario



                  if ($_FILES['foto']['name'] != '') {
                    $ext = end(explode('.',$_FILES['foto']['name']) );
                    $extensiones = array('jpg','jpeg','png','gif','JPG','JPEG','PNG','GIF','jpg');

                    if (!in_array($ext,$extensiones) ){
                      header('Location: ?view=cuenta&error=6');
                      exit;
                    }


                    $ruta = 'uploads/avatar/'.$this->$id;

                    if (file_exists($ruta . '.jpg') ) {
                      $ruta = 'uploads/avatar/'.$this->$id . '.jpg';
                      unlink($ruta);
                    }else if (file_exists($ruta . '.png')) {
                      $ruta = 'uploads/avatar/'.$this->$id . '.png';
                      unlink($ruta);
                    }else if (file_exists($ruta . '.jpeg')) {
                      $ruta = 'uploads/avatar/'.$this->$id . '.jpeg';
                      unlink($ruta);
                    }else if (file_exists($ruta . '.gif')) {
                      $ruta = 'uploads/avatar/'.$this->$id . '.gif';
                      unlink($ruta);
                    }else if (file_exists($ruta . '.JPG')) {
                      $ruta = 'uploads/avatar/'.$this->$id . '.JPG';
                      unlink($ruta);
                    }else if (file_exists($ruta . '.JPEG')) {
                      $ruta = 'uploads/avatar/'.$this->$id . '.JPEG';
                      unlink($ruta);
                    }else if (file_exists($ruta . '.PNG')) {
                      $ruta = 'uploads/avatar/'.$this->$id . '.PNG';
                      unlink($ruta);
                    }else if (file_exists($ruta . '.GIF')) {
                      $ruta = 'uploads/avatar/'.$this->$id . '.GIF';
                      unlink($ruta);
                    }
                      $ruta = 'uploads/avatar/'. $this->$id . '.' . $ext;
                      move_uploaded_file($_FILES['foto']['tmp_name'] . $ruta);

                  }

                  if ($c_cambio == 1) {
                    $tiempo_cambio = time() + (60*60*24*31);
                    $_SESSION['user'] = $this->user;
                  }else {
                      $tiempo_cambio = $_SESSION['cambio'];
                  }

                  $this->nombres = $db->real_escape_string($_POST['names']);
                  $this->apellidos = $db->real_escape_string($_POST['lastnames']);

                  $_SESSION['nombre'] = $this->nombres;
                  $_SESSION['apellido'] = $this->apellidos;
                      $_SESSION['fecha'] = $this->fecha;
                  $_SESSION['email'] = $this->email;
                  $_SESSION['user'] = $this->user;
                  $_SESSION['cambio'] = $tiempo_cambio;

                  //Aqui en la sentencia de (  ) va incluido esta sentencia ,**  fecha='$this->fecha' **
                  //No se coloca cuando tengas compartibilidad con el muestreo del calendario
                  $update = $db->query("UPDATE user  SET user='$this->user', email='$this->email', nombre='$this->nombres', apellido='$this->apellidos', fecha='$this->fecha',cambio='$this->Cambio' WHERE id='$this->id'; ");
                  $db->liberar($update);
                  $db->close();
                  header('Location: ?view=cuenta&success=1');

          }else{
            header('Location: ?view=cuenta&error=1');
          }
        }//EditUser

      }

     ?>
    
asked by Gamez 15.04.2017 в 04:47
source

0 answers