Welcome Guest, Not a member yet? Register   Sign In
Validation class problem...
#1

[eluser]nikefido[/eluser]
On my personal computer server (actually, both of them, one on a Mac and one on a PC) I am using the validation class as per the example in the User Guide.

However, when I moved this to my server, I am getting warnings:

http://www.freelanceplacement.com/Freela...hp/contact


I am assuming this is because of the error notification (ALL vs ALL ~ENOTICE) - sound right to all of you? If this is the "problem", was CI really made in that example in a way that would set off a warning from an undefined variable?


EDIT: setting it to ALL & ~E_NOTICE takes the warning away, however CI is not outputting the validation errors.




Any ideas? All I did was switch to a "live" server Sad
#2

[eluser]nikefido[/eluser]
update: setting the error_report to E_ALL on my local servers didn't change anything, so something else is stopping that variable from being set on the "live" server.

Perhaps it's version of PHP?

My local machine is running 5.2.5 while the live server is running PHP version 4.4.4 (My understanding was that CI was built for PHP 4)
(if not the version, gotta be a setting somewhere...)
#3

[eluser]xwero[/eluser]
Yes CI is build to work on php5 and php4 but if you use php5 only code in your application it will break on a php4 server. For instance you can't use __construct, self::, the static/public keywords, ...
#4

[eluser]nikefido[/eluser]
I haven't used any PHP5 specific code, and it's pretty much right out of the CI example in the Validation Class documentation Sad
#5

[eluser]xwero[/eluser]
Is the validation class loaded in the construct? it's a returning problem on the forum?
#6

[eluser]nikefido[/eluser]
[quote author="xwero" date="1205180443"]Is the validation class loaded in the construct? it's a returning problem on the forum?[/quote]

yes it is Big Grin

It works perfectly on my local server, but once i moved it I got those warnings.

I suppose I'll copy the controller code for ya:
Code:
<?php
class Contact extends Controller {

    function Contact() {
        parent::Controller();
        $this->load->helper('form');
        $this->load->library('validation');
        $this->load->library('email');
    }
    
    function index() {
        $this->asset_linker->load('public','css','mystyle.css');
        $this->asset_linker->load('public', 'js', 'validation.js');
        
        $data['attributes'] = array('id' => 'contact');
        
        $this->validation->set_error_delimiters('', '');
        
        $rules['name'] = "required";
        $rules['email'] = "required|valid_email";
        $rules['message'] = "required";
        
        
         $this->validation->set_rules($rules);
        
        $fields['name']    = 'name';
        $fields['email']    = 'email';
        $fields['message']    = 'message';
    
        $this->validation->set_fields($fields);
        
        if ($this->validation->run() == FALSE) {
            $this->load->view('contact_view', $data);
        } else{
            $this->dosend();
        }
    }
    
    function dosend() {
        $name = trim($this->input->post('name', TRUE));
        $email = trim($this->input->post('email', TRUE));
        $message = trim($this->input->post('message', TRUE));
        
        $this->email->clear();
        
        $config['mailtype'] = 'html';
        $config['wordwrap'] = TRUE;
        $config['newline'] = '\r\n';
        $this->email->initialize($config);
        
        $this->email->to('[email protected]');
        $this->email->from($name.'<'.$email.'>');
        $this->email->subject('Freelance Placement: Contact from ' . $name);
        
        $theMessage = '<p>'.$name . ' has sent the following message:</p><br>';
        $theMessage .= '<p>'. $message .'</p><br>';
        $theMessage .= '<p>Please send return emails to: ' . $email .'</p>';
        
        $this->email->message($theMessage);
        $this->email->cc('Digital-Surgeons<[email protected]>');
        
        if($this->email->send()) {
            $data['attributes'] = array('id' => 'contact');
            $data['success'] = 'Message Sent Successfuly';
            $this->load->view('contact_view', $data);
        } else {
            $data['attributes'] = array('id' => 'contact');
            $data['failure'] = 'Unable to Send Message';
            $this->load->view('contact_view', $data);
        }
    }
}

?&gt;

And then in the VIEW file, I have this - this is the email one, but i have this for all the fields (these are the variables that I'm getting the warning on - $email_error, $name_error etc etc):
Code:
&lt;?php echo $this->validation->email_error; ?&gt;
#7

[eluser]xwero[/eluser]
Load the validation library in the index method, that should solve it.

ps : now i'm going to stop for today to be a geek for the night Smile
#8

[eluser]nikefido[/eluser]
lol - thanks that did it.

However, I am curious as to why I had to do that when it worked perfectly the other way on other "test" servers.

Thanks for your help!




Theme © iAndrew 2016 - Forum software by © MyBB