Accurax Posted January 4, 2007 Share Posted January 4, 2007 Ive been staring at this for the last hour and i cant see where the mistake is.... ive had it working before.This morning i added the if statement, as i wanted to get new members to type there password twice.It all seems to work, except that it wont actually enter the info into the database, it just drops to the or die statment, can anyone see what ive done worng please?[code]<?phpinclude("info.inc");$connection=mysql_connect($host, $user, $passwd) or die ("Could not connect !");$db = mysql_select_db($database, $connection) or die ("Could not connect to Database"); $username = $_POST['username'];$password = $_POST['password'];$password2 = $_POST['password2'];$usermail = $_POST['usermail'];if ( $password == $password2){ $pass = md5($password); $key = md5($user_name); $query = "INSERT INTO members (user_name, email, password, key) VALUES ('$username', '$usermail', '$pass', '$key')"; $result = mysql_query($query) or die ("could not add user.");}else{ header("location: passnomatch.php"); } ?>[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted January 4, 2007 Share Posted January 4, 2007 Try putting backticks aroud the word [i]key[/i], I believe it to be a reserved word.[code=php:0]$query = "INSERT INTO members (user_name, email, password, `key`) VALUES ('$username', '$usermail', '$pass', '$key')";[/code] Quote Link to comment Share on other sites More sharing options...
mjlogan Posted January 4, 2007 Share Posted January 4, 2007 or also try[code=php:0]or die (mysql_error());[/code]to see what the actual error is Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted January 4, 2007 Share Posted January 4, 2007 OK.Can't see the form so make sure that has the correct fields.when comparing strings try using strcmp($password, $password2) == 0 (I think thats just good practice!)BUT the one thing that kills it is $key=md5($user_name);you have no $user_name - just $username so I suspect the key field in your database is not null and has no default value it will always get the md5 of null.PS Just read thorpes - key is indeed a reserved word!!! Quote Link to comment Share on other sites More sharing options...
Accurax Posted January 4, 2007 Author Share Posted January 4, 2007 thanks guys . i didnt realise key was reserved..... ive found a list of reserved words nowm sho i shouldnt have the problem again... thanks :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.