nphls Posted June 1, 2006 Share Posted June 1, 2006 I have a problem with a "registration form".The problem is that i cant enter the data into the MySQL database.I enter the data in the form correctly and then it goes to "registered.php" where it sould introduce the data in the database.Here's the code. At the end of it there's an IF for me to know if the data was inserted or no in the database. I always get "Not registered".Where's the mistake? Can you help me, because i just don't know where it is.[code]<HTML><HEAD> <TITLE>Registered.php</TITLE></HEAD><BODY><?$user = $_POST['username'];$pass = $_POST['password'];$email = $_POST['email'];$name = $_POST['name'];$country = $_POST['country'];$city = $_POST['city'];////////////////////////////////////////////////////////////////////////////////$host = 'localhost';$username = 'root';$database = 'project';$password = '';$connect = mysql_connect($host,$username,$password) ordie("Error connecting to Database! " . mysql_error());mysql_select_db($database , $connect) or die("Cannot select database! " . mysql_error());$request = "INSERT INTO users values(NULL,'$user','$pass','$email','$name','$country','$city',)";$results = mysql_query($request);if($results){echo "Registered"}else{echo "Not Registered";}mysql_close($connect);Die();?></BODY></HTML>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10966-help-with-a-register-form/ Share on other sites More sharing options...
wildteen88 Posted June 1, 2006 Share Posted June 1, 2006 You might have an error in your SQL query. To find out chnage the following code:[code]$results = mysql_query($request);if($results){echo "Registered"}else{echo "Not Registered";}[/code]to the following:[code]$results = mysql_query($request) or die("Unable to perform query: " . $result . "<br /><br />" . mysql_error());echo "Succesfully registered!";[/code]If there is a problem with the sql query then you'll get an [i]Unable to perform query message[/i] when you next run the code. If you dont understand the error message that may be shown you can post it here and we'll be able to help. Quote Link to comment https://forums.phpfreaks.com/topic/10966-help-with-a-register-form/#findComment-40949 Share on other sites More sharing options...
nphls Posted June 1, 2006 Author Share Posted June 1, 2006 Thanks for your help.The error was in synthax.I had this:[code]$request = "INSERT INTO users values(NULL,'$user','$pass','$email','$name','$country','$city',)";[/code]I just removed the comma after $city. However, thanks a lot for your help, otherwise i would'nt have found that error. [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10966-help-with-a-register-form/#findComment-40974 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.