Please could someone check this code for me as it is giving me 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 line .
Although this type of question has been ask by someone else before, but every ones code is different. thanks in advance.

        $conn=  mysql_connect($servername,$username,$password,$database)or die(mysql_error());

        if (!$conn) { 
            die('Could not connect: ' . mysql_error()); 
            echo 'Connected successfully'; 

        $sql="insert into datas(firstname,lastname,email,password,repassword,address)
        $result=mysql_query($sql,$conn) or die(mysql_error());          
        print "<h1>you have registered sucessfully</h1>";

        print "<a href='index.php'>go to login page</a>";
        else print "passwords doesnt match";
else print"invaild data";
4 Years
Discussion Span
Last Post by onofej

It looks like line 13 is your problem.
You are missing a few single quotes after the last couple of values.

Please, PLEASE do not use this code as it is. You are exposing yourself to some nasty SQL injection attacks by using unchecked GET variables.

At the very least, use mysql_real_escape_string


Thanks for all your reply, it is really scary reading through all your post/advice/caution
Please if anyone have any idea where i can purchase already written good code for member registration? i think buying it to complete my company site seems the way out for me now
thanks to you all


Hi onofej,

Sorry! It wasn't my intention to worry you so you didn't try and secure your code yourself.
SQL injection isn't something to be scared of, but it is something you need to be aware of and take precautions against.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.