Help me on this - El Forum - 06-06-2012
[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
Help me on this - El Forum - 06-06-2012
[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 ;-)
|