Guest User

Untitled

a guest
Jul 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. // Print Error if there is a duplicate Entry
  2. function duplicate ($key, $val, $table) {
  3. $query = "SELECT $key FROM $table WHERE $key='$val'"; $result = mysql_query($query);
  4. $row = mysql_num_rows($result);
  5. if ($row >= 1) {
  6. $this->error[$key] = ucfirst("$val already exists in the database for this field.");
  7. return $this->error;
  8. }
  9. }
  10.  
  11.  
  12. // Check for Duplicate Entries
  13. $error = $obj->duplicate("company_name", $newArray['company_name'], "clients");
  14. $error = $obj->duplicate("primary_email", $newArray['primary_email'], "clients");
  15.  
  16.  
  17. // I don't want to have to type in $error = $obj... Is there a way to do this w/o having to type that it in, so I just have to type $obj->dup...
Add Comment
Please, Sign In to add comment