Jump to content

Archived

This topic is now archived and is closed to further replies.

RalphLeMouf

Fatal error: Call to a member function where() on a non-object

Recommended Posts

which error logs do you need to see off of my MAMP module? Or do you need to see stuff from my logs folder on CI?

Share this post


Link to post
Share on other sites

I just got it! I noticed on config.php that enable query strings was set to false. I set it to true and it worked. loaded the wrong page and /validate_crendentials was in the url but that's a step.

 

In the meantime I was starting to transfer my files to the latest version. Do you think I'm ok working on 2.0.3 or should I continue to transfer it to 2.1.1?

 

thanks again for all of this help!

Share this post


Link to post
Share on other sites

it's actually defaulting to the index page when I hit submit no matter if the fields are filled out or not. It seems like a step in the right direction though

Share this post


Link to post
Share on other sites

Do you think I'm ok working on 2.0.3 or should I continue to transfer it to 2.1.1?

 

I highly recommend you do so. Releases exist for a purpose (primarily to fix bugs and insecurities).

 

You'll be jumping two releases, so you need to follow both of these steps:

http://codeigniter.com/user_guide/installation/upgrade_210.html

http://codeigniter.com/user_guide/installation/upgrade_211.html

 

it's actually defaulting to the index page when I hit submit no matter if the fields are filled out or not. It seems like a step in the right direction though

Check your form_open to see where it points and then check that controller/method to see if is anything that would cause problems.

Share this post


Link to post
Share on other sites

I have gone back to the most stripped down version of logging in an user. The form open location is "auth/validate_credentials" as that seems logical. Moreover when I take that out. After hitting submit on the login page it takes me to the index.php ( default view ) no matter what!

 

I also did the updates.

 

Here is what I currently have:

 

Model:

 

<?php

class User_model extends CI_Model {

function validate() 
{

	$this->db->where('email', $this->input->post('email'));
	$this->db->where('password', sha1($this->input->post('password')));
	$query = $this->db->get('users');

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

 

View:

 

<title>Login</title>

<!--MAKE SURE SIGNED OUT HEADER IS IMPLEMENTED FOR ALL SIGNED OUT PAGES INCLUDING THIS ONE-->

<div class="structure clearfix">
<h1 class="title_header">
	Sign In
</h1>
<div id="signin_form">
	<?php
	echo validation_errors(); 
	echo form_open('auth/validate_credentials');
	echo "<div class='form_text_signin'>";
	echo "Email";
	echo "</div>";
	echo form_input('email');
	echo "<div class='form_text_signin'>";
	echo "Password";
	echo "</div>";
	echo form_input('password');
	echo form_submit('submit', 'Submit');
	echo form_close();
	?>
</div>
</div>

 

Controller:

 

 

<?php

class Auth extends CI_Controller {

function __construct()

{

// Call the Model constructor

parent::__construct();

}

 

// this is automatically called if no other function is called

// it simply turns around and calls the login() function to show the login page

 

public function index() {

 

$this->login();

}

 

public function login() {

$data['main_content'] = 'auth/login';

$this->load->view('includes/templates/main_page_template', $data);

}

 

function validate_crendentials()

{

echo "<pre>";

$this->output->enable_profiler(TRUE);

echo "</pre>";

$this->load->model('user_model');

$this->user_model->validate();

 

if($query)

{

$data = array(

'email' => $this->input->post('email'),

'is_logged_in' => true

);

 

$this->session->set_userdata($data);

redirect('account/dashboard');

}

else

{

$this->index();

}

}

}

 

 

 

 

Share this post


Link to post
Share on other sites

Ok - this is getting a little despressing  :'( haha

 

I went ahead and just tried to transfer all of my files to version 2.1.2 and not worry about updating my current files twice because I was two version behind. I am STILL having data base issues from the get go.

 

A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: core/Loader.php

Line Number: 346

 

and here is that line in my files:

 

 

require_once(BASEPATH.'database/DB.php');

	if ($return === TRUE)
	{
		return DB($params, $active_record);
	}

	// Initialize the db variable.  Needed to prevent
	// reference errors with some configurations
	$CI->db = '';

	// Load the DB class
	$CI->db =& DB($params, $active_record);
}

Share this post


Link to post
Share on other sites

Unable to connect to your database errors stem from your config/database.php file.  Either your database chosen, the path to it, user name, or password are incorrect.

Share this post


Link to post
Share on other sites

right - that is my concern. it very well should be:

 

 

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'root';
$db['default']['database'] = 'cysticlife_CI';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

Share this post


Link to post
Share on other sites

What you posted is only half of the solution, of course - as you must ensure you have a database running that accepts those parameters.  This thread, however, has lost it's scope, and if you desire further general assistance, you can PM me and we can set up a training session for a reasonable cost.  Else, please hone in on a specific issue and the community may be able to aide you.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.