Web Analytics Made Easy -
StatCounter Error with email registration - CodingForum

Announcement

Collapse
No announcement yet.

Error with email registration

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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.

    Comment


    • #3
      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; Aug 23, 2011, 01:46 AM. Reason: found problem

      Comment

      Working...
      X