Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problems with simple mailing list add

    Hello,

    I'm really new to php and am looking to create a database from people adding their email address using a submit button. I'm getting the following error:
    Code:
    Parse error: syntax error, unexpected T_VARIABLE in /usr/local/psa/home/vhosts/******.com/httpdocs/emailadd.php on line 15
    (I've starred out the webaddress)

    Here is the HTML form code:
    Code:
    <html>
    <body>
    
    <form action="emailadd.php" method="post">
    Email: <input type="text" name="emailadd" />
    <input type="submit" />
    </form>
    
    </body>
    </html>
    and this is the php code:
    PHP Code:
    <?php

    $user
    ="******";
    $password="********";
    $database="MailingList";
    $connection mysql_connect('localhost',$user,$password);
    if (!
    $connection)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db($database)


    $emailadd $_POST['emailadd'];

    if(
    $emailadd != ""){
        
    $query="INSERT INTO 'EmailAddresses'('Email') VALUES ($emailadd)";
        }

    mysql_close($connection);

    ?>
    I'm a bit stuck, if anyone can help me it will be greatly appreciated.

    Thanks

    Graeme

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Missing semi-colon:
    Code:
    mysql_select_db($database);
    John

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    You should put single-quotes around $emailadd in your query, and pass it through mysql_real_escape_string() as well.

  • #4
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for all your help. Its now working. Smiley faces all round!


  •  

    Posting Permissions

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