2016-07-01 9 views
0

Ich versuche, ein Login-System zu machen, und ich bin auf diese Datenbank FehlerWie mit CodeIgniter Fehler Nummer 1064 umgehen?

Sie haben einen Fehler in Ihrer SQL-Syntax bekommen; Überprüfen Sie das Handbuch, das Ihrer MariaDB-Serverversion entspricht, für die richtige Syntax in der Nähe von 'SET last_activity = 1467333267, user_data =' a: 3: {s: 9: \ "Benutzerdaten \"; s: 0: \ "\" ' in Zeile 1

UPDATE SET last_activity = 1467333267, user_data = a: 3: {s: 9: \ "user_data \"; s: 0: \ "\"; s: 5: \ "email \"; s: 16: \ "[email protected] \"; s: 12: \ "is_logged_in \"; i: 1;}‘WHERE session_id = '570d7ba3d7f11a9a35264ed276368480'

Dateiname: C:/xampp/htdocs/CodeIgniter /system/database/DB_driver.php

Zeilennummer: 691

Hier ist mein Controller-Code:

class Template extends CI_Controller { 


    public function index() 
    { 
     $this->login(); 
    } 

    public function login() 
    { 
     $this->load->view('Login Template.php'); 
    } 

    public function admin() 
    { 
     if ($this->session->userdata('is_logged_in')) { 
      $this->load->view('Template 3.php');  
     } 
     else { 
      echo 'cannot login'; 
     } 
    } 

    public function login_validation() 
    { 
     $this->load->library('form_validation'); 

     $this->form_validation->set_rules('email' , 'Email', 'required|trim|callback_validate_credentials'); 
     $this->form_validation->set_rules('password' , 'Password', 'required|md5|trim'); 

     if ($this->form_validation->run()) { 
      $data = array (
       'email' => $this->input->post('email'), 
       'is_logged_in' => 1 
       ); 

      $this->session->set_userdata($data); 
      redirect('template/admin'); 
     } 
     else 
     { 

      echo 'fail'; 
     } 

    } 

    public function validate_credentials() 
    { 
     $this->load->model('users'); 

     if ($this->users->can_log_in()) { 
      return true; 
     } 
     else 
     { 
      $this->form_validation->set_message('validate_credentials', 'fail to login'); 
      return false; 
     } 
    } 



    public function about() 
    { 
     $this->load->view('About this site.php'); 
    } 

    public function logout() 
    { 
     $this->session->sess_destroy(); 
     redirect('template/login'); 
    } 

Und hier ist mein Modellcode:

class Users extends CI_Model 
{ 

    public function can_log_in() 
    { 
     $this->db->where('email', $this->input->post('email')); 
     $this->db->where('password', md5($this->input->post('password'))); 

     $query = $this->db->get('registered_users'); 

     if ($query->num_rows() == 1) { 
      return true; 
     } 
     else 
     { 
      return false; 
     } 
    } 

Antwort

0

Tabellenname aus der SQL-Anweisung fehlt.

+0

können Sie mir zeigen, wie es geht. Ich bin nur neu in SQL und PHP –