• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help me on this

#1
[eluser]GI-Joe[/eluser]

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class User extends CI_Controller {
public function index()
{
  $this->load->view('user/login');
}

public function verifyUser()
{
  
  $username= $this->input->post('username');
  $password= $this->input->post('password');
  
  $this->load->model('user_model');
  $this->user_model->authenticateUser($username,$password);
  
}
}

Code:
<?php
class User_model extends CI_Model {



public function authenticateUser($user,$pass)
{
  $this->db->select('username,password');
  
  echo $this->db->where('username',$user);
  echo $this->db->where('password',$pass);

  $q = $this->db->get('users');

  if($q->num_rows()>0)
  {
   echo 'success';
   return true;
  }
  else
  {
   echo 'failed to authenticate';
   return false;
  }
}
}
?>

When I run this code it is giving me following error

Code:
A PHP Error was encountered

Severity: 4096

Message: Object of class CI_DB_mysql_driver could not be converted to string

Filename: models/user_model.php

Line Number: 10
A PHP Error was encountered

Severity: 4096

Message: Object of class CI_DB_mysql_driver could not be converted to string

Filename: models/user_model.php

Line Number: 11
success

#2
[eluser]GI-Joe[/eluser]
Code:
<?php
class User_model extends CI_Model {



public function authenticateUser($user,$pass)
{
  $this->db->select('username,password');
  
  [color=red]echo[/color] $this->db->where('username',$user);
  [color=red]echo[/color] $this->db->where('password',$pass);

  $q = $this->db->get('users');

  if($q->num_rows()>0)
  {
   echo 'success';
   return true;
  }
  else
  {
   echo 'failed to authenticate';
   return false;
  }
}
}
?>

Just have to remove highlighted echo ;-)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.