Thread: SQL - Parse error: syntax error, unexpected T_STRING in /hosted/domains/d/c/dcfilms

Results 1 to 7 of 7
  1. #1 SQL - Parse error: syntax error, unexpected T_STRING in /hosted/domains/d/c/dcfilms 
    Registered Member
    Join Date
    Jan 2010
    Posts
    145
    Thanks
    8
    Thanked 19 Times in 6 Posts
    Rep Power
    41
    I receive this error attempting to insert some text into the DB

    Parse error: syntax error, unexpected T_STRING in /hosted/domains/d/c/dcfilms.org/public_html/register.php on line 17

    My script:

    Code:
    <?php
    $host="mysql"; // Host name
    $username="15557_test"; // Mysql username
    $password="********"; // Mysql password
    $db_name="15557_test"; // Database name
    $tbl="Users"; // Table name
    mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
    mysql_select_db("$db_name")or die("cannot select DB");
    
    $passw = $_POST["pass"];
    $enc = md5($passw);
    $user = $_POST["user"];
    $email = $_POST["email"];
    echo "Username: " . $user . "<br />";
    echo "Password: " . $enc . "<br />";
    echo "E-mail: " . $email . "<br />";
    INSERT INTO $tbl(user, pass, email)VALUES('$user', '$enc', '$email') //line 17
    echo "Account " . $user . " created! Log in <a href="loginn.php">here</a>
    ?>
    I realize it's not the best method for registrating, etc etc. But it's just a side-project.
    Thanks in advance :s

    EDIT:
    I'm retarded lol. Mod or admin close this please...
     

  2. #2  
    Doctor p - Sweet Shop


    Join Date
    Apr 2007
    Age
    20
    Posts
    6,841
    Thanks
    142
    Thanked 590 Times in 340 Posts
    Rep Power
    2361
    mysql_query ("INSERT INTO $tbl(user, pass, email)VALUES('$user', '$enc', '$email')");
     

  3. #3  
    Registered Member
    Join Date
    Jan 2010
    Posts
    145
    Thanks
    8
    Thanked 19 Times in 6 Posts
    Rep Power
    41
    Quote Originally Posted by Nathan View Post
    mysql_query ("INSERT INTO $tbl(user, pass, email)VALUES('$user', '$enc', '$email')");
    fix'd before i even read thread. sorry bout that.
    Thanks anyways
     

  4. #4  
    Doctor p - Sweet Shop


    Join Date
    Apr 2007
    Age
    20
    Posts
    6,841
    Thanks
    142
    Thanked 590 Times in 340 Posts
    Rep Power
    2361
    Quote Originally Posted by Magestickown View Post
    fix'd before i even read thread. sorry bout that.
    Thanks anyways

    Np, did my fix work?
     

  5. #5  
    Registered Member
    Join Date
    Jan 2010
    Posts
    145
    Thanks
    8
    Thanked 19 Times in 6 Posts
    Rep Power
    41
    Quote Originally Posted by Nathan View Post
    Np, did my fix work?
    Yes, but before I read the thread I was looking at the code and realized I tried to make a query without the prefix.

    Do you know how I could display message when a username already exists in the DB? This is my first registration system that I made w/ out a tut etc etc. I already have the username set to "unique".
     

  6. #6  
    Doctor p - Sweet Shop


    Join Date
    Apr 2007
    Age
    20
    Posts
    6,841
    Thanks
    142
    Thanked 590 Times in 340 Posts
    Rep Power
    2361
    Code:
    $query = mysql_query ("INSERT INTO $tbl(user, pass, email)VALUES('$user', '$enc', '$email')");
    
    if (!$query) {
     echo("<SCRIPT LANGUAGE='JavaScript'> 
                                window.alert('Username already exists.') 
                 </SCRIPT>"); 
    }
     

  7. #7  
    Registered Member
    Join Date
    Jan 2010
    Posts
    145
    Thanks
    8
    Thanked 19 Times in 6 Posts
    Rep Power
    41
    Quote Originally Posted by Nathan View Post
    Code:
    $query = mysql_query ("INSERT INTO $tbl(user, pass, email)VALUES('$user', '$enc', '$email')");
    
    if (!$query) {
     echo("<SCRIPT LANGUAGE='JavaScript'> 
                                window.alert('Username already exists.') 
                 </SCRIPT>"); 
    }
    Got everything working + blocked sql injections
    Thanks Nathan
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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