Duplicate Entry - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Duplicate Entry (/showthread.php?tid=50763) Pages:
1
2
|
Duplicate Entry - El Forum - 04-07-2012 [eluser]Zed[/eluser] Hi all, i keep getting double entry in my db. how do i stop it? guess my method is wrong. part of my code below thanks Code: $form_data = array( thanks again Duplicate Entry - El Forum - 04-07-2012 [eluser]toopay[/eluser] @Zed, you evaluating query object, which will returing TRUE or FALSE, so you will never get to first condition. Try : Code: $query = $this->db->query('SELECT email FROM reg_users'); Duplicate Entry - El Forum - 04-07-2012 [eluser]InsiteFX[/eluser] Code: if ($query->num_rows() > 1) Duplicate Entry - El Forum - 04-07-2012 [eluser]Samus[/eluser] You should actually really be checking if it's equal to 1. Emails are unique to a user, they should only occur once. Code: if ($query->num_rows() == 1) Duplicate Entry - El Forum - 04-10-2012 [eluser]Zed[/eluser] have tried all this, but still no luck. i even tried Code: $query = $this->db->query('SELECT email FROM reg_users'); what it does here is that it does not parse any data into the database but rather echos duplicate entry even when its not duplicate. any suggestions? thanks Duplicate Entry - El Forum - 04-10-2012 [eluser]zoopstud[/eluser] Your not actually checking for a specific email, you are grabbing them all so will always be more than 1 unless the tables empty, you need a where clause to check for the given email. you could always set email as unique in table, and handle it that way. Duplicate Entry - El Forum - 04-11-2012 [eluser]Zed[/eluser] [quote author="zoopstud" date="1334095780"]Your not actually checking for a specific email, you are grabbing them all so will always be more than 1 unless the tables empty, you need a where clause to check for the given email. you could always set email as unique in table, and handle it that way.[/quote] even with the other parameter still the same problem thanks though Duplicate Entry - El Forum - 04-11-2012 [eluser]RiccardoC[/eluser] Something like this Code: $query = $this->db->query("SELECT email FROM reg_users WHERE email = '" . $data[ 'email' ] . "'"); Duplicate Entry - El Forum - 04-11-2012 [eluser]zoopstud[/eluser] [quote author="Zed" date="1334146380"] even with the other parameter still the same problem thanks though[/quote] What parameter? Code: $this->db->select('email'); Duplicate Entry - El Forum - 04-13-2012 [eluser]Zed[/eluser] [quote author="zoopstud" date="1334147134"][quote author="Zed" date="1334146380"] even with the other parameter still the same problem thanks though[/quote] What parameter? Code: $this->db->select('email'); Still not working. I wonder why? |