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 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2011
    Location
    Maryland
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Error with email registration

    How is every doing? I'm working on an email registration script, final thought I was done, but I keep getting this error read out:

    Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5
    Here is a bit of my code:

    PHP Code:
    <?php

    mysql_connect
    ("localhost""USERNAME""PASSWORD") or die("Could not connect to database");

    mysql_select_db("email") or die(mysql_error());

    if (
    $_POST['form_submitted'] == '1') {
        
    ## The form was submitted, the user is registering.
        
        
    $activationKey mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();
        
        
    $username mysql_real_escape_string($_POST["username"]);
        
    $password mysql_real_escape_string($_POST["password"]);
        
    $email mysql_real_escape_string($_POST["email"]);
    I think it is referring to my
    PHP Code:
    mysql_select_db("email") or die(mysql_error()); 
    I don't see anything wrong with the line, but then again I'm a newbie to php. Does anyone know why I am getting this error and how I can fix it?

    Thank you for your help!

  • #2
    New Coder
    Join Date
    Jan 2010
    Location
    Birmingham, MI
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    it isn't referring to the line you think it is. It is referring to your SQL statement. Could you post that? I can already tell you though, that there is probably a problem with the way it is quoted and escaped.

  • Users who have thanked JamesOxford for this post:

    Damien118 (08-23-2011)

  • #3
    New Coder
    Join Date
    Jan 2011
    Location
    Maryland
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by JamesOxford View Post
    it isn't referring to the line you think it is. It is referring to your SQL statement. Could you post that? I can already tell you though, that there is probably a problem with the way it is quoted and escaped.
    Here is my statement:

    PHP Code:
        $sql "INSERT into users(username, password, email, activationkey, status)
        
                VALUES
                
                ('$username', '$password', '$email', 'activationKey', 'verify'"

    found my mistake, but I never would have found it without your insight! Thanks!
    Last edited by Damien118; 08-23-2011 at 07:46 AM. Reason: found problem


  •  

    Posting Permissions

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