Welcome Guest, Not a member yet? Register   Sign In
form validation error
#1

[eluser]the_unforgiven[/eluser]
Hi All,

I'm getting this error:

A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: libraries/Form_validation.php
Line Number: 320

Fatal error: Call to a member function load() on a non-object in /home/site/public_html/system/libraries/Form_validation.php on line 320

Here's the controller
Code:
function send()
{

  // Set Validation Rules
  $this->form_validation->set_rules('name', 'Name', 'required');
  $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
  $this->form_validation->set_rules('phone', 'Phone', 'trim|required');
  $this->form_validation->set_rules('message', 'Message', 'trim|required');
  
  // Validation runs false rteun back to form and show errors
  if ($this->form_validation->run() == FALSE) {
  
   $this->index();
  }
  // If everything is filled out with no errors procced with sending the form to email and database
  else {
                 echo 'Submitted';
                }
}

I have tried commenting out line by line but still no joy then if i comment out them all it does kinda work, just wondering why this is not working can anyone shed some light on this for me?

Help much appreciated.
#2

[eluser]the_unforgiven[/eluser]
Anyone?
#3

[eluser]Mauricio de Abreu Antunes[/eluser]
Did you load form_validation? :-)
#4

[eluser]the_unforgiven[/eluser]
Yes via autoload.php

Code:
| -------------------------------------------------------------------
|  Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in the system/libraries folder
| or in your application/libraries folder.
|
| Prototype:
|
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
*/

$autoload['libraries'] = array('database', 'session', 'form_validation', 'upload', 'pagination', 'email');


/*
| -------------------------------------------------------------------
|  Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['helper'] = array('url', 'file');
*/

$autoload['helper'] = array('form', 'html', 'url', 'date', 'text', 'cookie','security', 'ckeditor', 'file');


/*
#5

[eluser]Mauricio de Abreu Antunes[/eluser]
Comment out your send() call, please.
Even that function is being called from a form.
#6

[eluser]the_unforgiven[/eluser]
I commented out the send() function and got a 404 then cos the page contact/send doesn't exsist
#7

[eluser]Mauricio de Abreu Antunes[/eluser]
Ah, ok! Forget my idea.

Please, try to load form_validation in your controller.
#8

[eluser]the_unforgiven[/eluser]
Added both:

$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');

in controller but still same error.
#9

[eluser]Matalina[/eluser]
It looks like you are trying to load on something that is not a ci object. Your form validation is being called other wise the library wouldn't be giving you the error.

My guess is that something in your view is wrong.
#10

[eluser]Mauricio de Abreu Antunes[/eluser]
Show your view, please.
How is your "validation_errors" in your view?




Theme © iAndrew 2016 - Forum software by © MyBB