SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    E-business guru Eirik's Avatar
    Join Date
    Nov 2000
    Location
    Oslo, Norway
    Posts
    413
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I've started to write my own simple mailing list management system using MySQL and PHP, and I've encountered a problem pretty early in the process.

    For my subscriber to unsubscribe, I provide a form (among other methods) to fill in with their Email address, and then the Email address provided will be removed.

    The code for doing this goes a little something like this:

    // Delete the requested Email address
    if (!mysql_query('DELETE FROM Subscriber WHERE Email LIKE "$Email"')) {
    echo("The Email address you provided does not exist in the database. Please go back and try again.");
    exit();
    }

    Though I know that the variable $Email contains the Email address, and the error message doesn't appear, the Email address is not removed. What am I doing wrong?

    Thanks in advance !
    Sincerely,

    Eirik Johansen
    Netmaking AS

  2. #2
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try..
    <?
    $q=mysql_query("DELETE FROM Subscriber WHERE Email ='$Email'") or die ("The Email address you provided does not exist in the database. Please go back and try again.");
    ?>

    I am assuming the problem is the double quotes around '$Email'

    another possibility is whitespace in either $Email or the entry in the DB - try $Email=trim($Email); before the query - (and when you enter the email in the DB)

    just a couple of guesses?

  3. #3
    E-business guru Eirik's Avatar
    Join Date
    Nov 2000
    Location
    Oslo, Norway
    Posts
    413
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi firepages,

    It was the quotes that did the trick. Thanks a million!
    Sincerely,

    Eirik Johansen
    Netmaking AS


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
  •