Welcome Guest, Not a member yet? Register   Sign In
Parse error: syntax error, unexpected T_ELSE
#1

[eluser]Unknown[/eluser]
Parse error: syntax error, unexpected T_ELSE in D:\xampp\htdocs\myfirstcodeigniter\application\controllers\user.php on line 31

<?php
class User extends CI_Controller {

function __construct()
{
parent::__construct();
$this->view_data['base_url'] = base_url();
$this->load-model('User_model');
}

function index()
{
$this->register();
}

function register()
{

$this->load->library('form_validation');

$this->form_validation->set_rules('name','Name', 'trim|required|alpha_numeric|min_lenth[6]|xss_clean|strtolower');
$this->form_validation->set_rules('username','Username', 'trim|required|alpha_numeric|min_lenth[6]|xss_clean|strtolower|callback_username_not_exits');
$this->form_validation->set_rules('email','Email', 'trim|required|alpha_numeric|min_lenth[6]|xss_clean');
$this->form_validation->set_rules('password','Password', 'trim|required|alpha_numeric|min_lenth[6]|xss_clean');
$this->form_validation->set_rules('passwordC','Confirm Password', 'trim|required|alpha_numeric|min_lenth[6]|match[password]|xss_clean');

if ($this->form_validation->run() == FALSE);
{
$this->load->view('user_view',$this->view_data);
}
else
{
$username = $this->input->-post('username');
$name = $this->input->-post('name');
$password = $this->input->-post('password');
$email = $this->input->-post('email');

$activation_code = $this->_random_string(10);

$this->User_model->register_user(u$sername, $name, $password, $email);

}

}
function username_not_exist($username)
{
$this->form_validation->set_message('username_not_exits','That %s already exists. Please choose a different username and try again.');

if ($this->User_model->check_exist_username($username))
{
return false;
}
else
{
return true;
}
}
}
?>
#2

[eluser]ChrisMiller[/eluser]
Well here is your problem..
Code:
if ($this->form_validation->run() == FALSE);
Should be...
Code:
if ($this->form_validation->run() == FALSE)

And this also...
Code:
$this->User_model->register_user(u$sername, $name, $password, $email);

Should be...

Code:
$this->User_model->register_user($username, $name, $password, $email);

You should check out this:
Code:
pear.php.net/manual/en/standards.php
it is coding standards for writing clear php syntax. Every developer has his own unique way of doing things but it makes it easier for other developers to interpert things.
#3

[eluser]InsiteFX[/eluser]
You should also read this! Next time you post code please use code tags! If you do not know the code tags use the advanced editor POST REPLY.

CodeIgniter User Guide - General Style and Syntax

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB