Results 1 to 8 of 8

Thread: Storing emails in MySQL

  1. #1
    Senior Member
    Join Date
    Apr 2004
    Posts
    228

    Storing emails in MySQL

    Hi Everyone!

    Just got one question.

    I'm trying to store e-mails in MySQL.

    I know I can stor it as simple varchar, but I wanted to put some constraints on it.

    Although I can't find any place, which give me some clear info on how to do it.

    I though to do it like this

    ...
    email varchar check(email in ('*@*.*'))
    ...;

    Will it be correct or not? Is there a better way to do it?



    P.S. For all those search Google adviser.

    Please keep that advise for yourself. I ALREADY SEARCHED!

    So unless you find something I didn't don't bother.



    I'll go through the tutorial once again though. I might of missed something
    Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying

  2. #2
    Socialist Utopia Donkey Punch's Avatar
    Join Date
    Sep 2004
    Location
    In the basement
    Posts
    319
    Here is something that may help you. http://dev.mysql.com/tech-resources/...ne/part_1.html
    In loving memory of my step daughter 1987-2006

    Liberty In North Korea

  3. #3
    this can be done in PHP before storing the addy -> http://www.sitepoint.com/article/use...il-address-php

    v_Ln

  4. #4
    Senior Member
    Join Date
    Apr 2004
    Posts
    228
    Thanks guys. The info you gave me is very useful, but nevertheless not exactly what I need.

    I'm just trying to put in some validation rules in place, so that the person who'll be looking after everything couldn't do to much harm, even if he want's to.

    Couldn't trust him even a little bit with the work
    Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying

  5. #5
    Socialist Utopia Donkey Punch's Avatar
    Join Date
    Sep 2004
    Location
    In the basement
    Posts
    319
    Then you will need regular expressions in the scripting language you use to filter the input before it is stored the in the database.

    http://www.zend.com/zend/spotlight/ev12apr.php

    If you are using another lanuage, check the docs on how to use regular expressions, if it is supported.
    In loving memory of my step daughter 1987-2006

    Liberty In North Korea

  6. #6
    Ninja Code Monkey
    Join Date
    Nov 2001
    Location
    Washington State
    Posts
    1,027
    Most people handle what you are trying to do in the business layer of their web application. The check you have down is about the best you can do for email address validation.
    "When I get a little money I buy books; and if any is left I buy food and clothes." - Erasmus
    "There is no programming language, no matter how structured, that will prevent programmers from writing bad programs." - L. Flon
    "Mischief my ass, you are an unethical moron." - chsh
    Blog of X

  7. #7
    Senior Member
    Join Date
    Mar 2004
    Posts
    557
    Hi

    As it has been said, you should carefully check any input
    in your database, before you actually start any communication
    with it (eg. using SQL). The standard approach involves some
    front end, which sends input data to a trusted application
    (e.g. your server-side php script), which performs the
    validation. Never ever trust client-side checks.


    In addition

    Scan your database regularily for entries which does not
    follow your constraints. This should never happen by design,
    but if, there are other data flows you are not controlling.
    Search and eliminate.

    Cheers.
    If the only tool you have is a hammer, you tend to see every problem as a nail.
    (Abraham Maslow, Psychologist, 1908-70)

  8. #8
    Senior Member
    Join Date
    Apr 2004
    Posts
    228
    Unfortunately I'm only producing the database, and will have not control over it what so ever
    Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •