Welcome Guest, Not a member yet? Register   Sign In
Database Error
#1

Greetings All,
Am less than a month old in learning CI, I have a problem:
I'm using the form_validation library to validate form inputs.
Two of the fields (username and email fields) has to check in the DB that the user input is unique and doesn't already exist in the DB - I'm creating a user system using ion_auth. The code for the validation of the fields are as follows

PHP Code:
$this->form_validation->set_rules('name''Display Name''is_unique|isme_users.username|required');
        
$this->form_validation->set_rules('email''Email''valid_email|is_unique|isme_users.email|required'); 

I'm getting the error in the attached picture.

   

I'm running LAMPP on Ubuntu and my server parameters are as follows (from PHPMyAdmin)
  • Apache/2.4.29 (Unix) OpenSSL/1.0.2n PHP/7.2.0 mod_perl/2.0.8-dev Perl/v5.16.3

  • Database client version: libmysql - mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $

  • PHP extension: mysqli[Image: dot.gif] curl[Image: dot.gif] mbstring[Image: dot.gif]

  • PHP version: 7.2.0
My knowledge of databases and SQL re li,ited and am still laerning them.
Help is needed and appreciated.
Reply
#2

You need to put the table inside brackets.
https://www.codeigniter.com/userguide3/l...-reference
PHP Code:
$this->form_validation->set_rules('name''Display Name''required|is_unique[isme_users.username]');
$this->form_validation->set_rules('email''Email''valid_email|required|is_unique[isme_users.email]'); 
Reply
#3

(This post was last modified: 01-21-2018, 11:41 AM by enelson.)

(01-20-2018, 01:43 PM)jreklund Wrote: You need to put the table inside brackets.
https://www.codeigniter.com/userguide3/l...-reference
PHP Code:
$this->form_validation->set_rules('name''Display Name''required|is_unique[isme_users.username]');
$this->form_validation->set_rules('email''Email''valid_email|required|is_unique[isme_users.email]'); 
Thank you, that helped.
Please, how can I edit the errors displayed?
The picture below shows the error displayed when I provide an already taken email. I would like to display something like:
"The Email has already been taken".
   

Edit
Found it, edited the form_validation language file.
Reply
#4

I recommend that you do it this way, in case you overwrote the system language file.
https://www.codeigniter.com/userguide3/l...r-messages
Reply
#5

(01-21-2018, 02:23 PM)jreklund Wrote: I recommend that you do it this way, in case you overwrote the system language file.
https://www.codeigniter.com/userguide3/l...r-messages

Thank you for the recommendation.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB