SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Location
    uk
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    explode function query

    Hi,

    The explode function separates a bit i added to an email, so that the email can be used -

    if ($guest_pass == "12vv22vv2")
    {
    $Email_raw = $row['Email'];
    $Email_array = explode(_,$Email_raw);
    $Email = $Email_array[1];
    }
    else {
    $Email = $row['Email'];
    }

    this separates the 12324543_

    from

    12324543_email123address@something.com

    The problem arises when the customers email address has a hyphen it it, as this code finds all the hyphens.

    12324543_email123_address@something.com

    then becomes - email123

    How can i stop the code at the first hyphen?

    I have tried

    $Email_array = explode(_,$Email_raw,1);

    But that just removed the whole email address


    Thanks

    Paul

  2. #2
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Why don't you use delimiter that cannot be in the email address?
    -- Jelena --

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Location
    uk
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, good advice.

    I had thought of this about 20 minutes ago! (honestly :-), but not being totally up on this stuff, i'm not sure what is not allowed in an email address, but would work as a delimiter :-(

    I think i will investigate what i can use and do this as it seems to be the best way forwards.

    Just have to update all my guest customers in admin that have the old delimiter then :-(

    Thanks again

    Paul

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why do you even need to tack this extra string onto thier email address? you cannot store it seperately? seems like you could just make a new field for your database to hold this.

  5. #5
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You could use a space? or comma?
    -- Jelena --

  6. #6
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Location
    uk
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have two type of guests, ones that the site remembers and those that don't want to be remembered - guests. The shopping code was built for people to log in and i have modified it so that they have a choice.

    I am not fully experienced, but so that the site does not recognise their email and say 'already registered', i put the date and the seconds before their email address and all works well, except for this new problem.

    Then, when the site sends them an order email and a dispatched email, the prefix is stripped off and the email works.

    There may be clevere ways, but in my limited experience, i chose this way.


Bookmarks

Posting Permissions

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