conan318 Posted August 4, 2011 Share Posted August 4, 2011 check the manual that corresponds to your MySQL server version for the right syntax to use near i have set up wamp server Server: localhost (localhost via TCP/IP) Server version: 5.5.8-log Protocol version: 10 MySQL charset: UTF-8 Unicode (utf8) the code works on online but when using the wamp server i get this error error in registration 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 ') VALUES ('QLD','18', 'test', 'Australia' , 'test', '098f6bcd4621d373cade4e83262' at line 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; " /> <title>Untitled Document</title> </head> <?php /* This code will make a connection with database */ mysql_connect("localhost", "", "")or die("cannot connect"); mysql_select_db("main")or die("cannot select DB"); /* Now we will store the values submitted by form in variable */ $username=$_POST['username']; $pass=$_POST['password']; $email=$_POST['email']; $postcode=$_POST['postcode']; $suburb=$_POST['suburb']; $sex=$_POST['sex']; $city=$_POST['city']; $Country=$_POST['Country']; $age=$_POST['age']; $state=$_POST['state']; /* we are now encrypting password while using md5() function */ $password=md5($pass); $confirm_password=$_POST['confirm_password']; /* Now we will check if username is already in use or not */ $queryuser=mysql_query("SELECT * FROM users WHERE username='$username' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { echo "Sorry, ".$username." is already been taken."; } else { /* Now we will check if username is already in use or not */ $queryuser=mysql_query("SELECT * FROM users WHERE email='$email' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { echo "Sorry, ".$email." has already been taken."; } else { /* now we will check if password and confirm password matched */ if($pass != $confirm_password) { echo "Password and confirm password fields were not matched"; } else { if($age < "18") { echo "you must be 18 years or older to join"; } else { if($email = "") { echo "you must enter an email address"; } else { if($postcode == "") { echo "you must your postcode"; } else { if($city == "") { echo "you must enter your city"; } else { if($suburb == "") { echo "you must enter your suburb"; } else { if($state == "") { echo "you must enter your state"; } else { /* Now we will write a query to insert user details into database */ $insert_user=mysql_query("INSERT INTO users (state, age, city, Country, username, password, email, postcode, suburb, sex,) VALUES ('$state','$age', '$city', '$Country' , '$username', '$password', '$email', '$postcode', '$suburb', '$sex') "); if($insert_user) { header("location:signupnow.php"); die();} else { { echo "error in registration".mysql_error(); } } /* closing the if else statements */ }}}}}}}}} ?> <body> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/243779-wamp-server/ Share on other sites More sharing options...
phpSensei Posted August 4, 2011 Share Posted August 4, 2011 sex,) see that extra comma? Remove it. Code should now be <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; " /> <title>Untitled Document</title> </head> <?php /* This code will make a connection with database */ mysql_connect("localhost", "", "")or die("cannot connect"); mysql_select_db("main")or die("cannot select DB"); /* Now we will store the values submitted by form in variable */ $username=$_POST['username']; $pass=$_POST['password']; $email=$_POST['email']; $postcode=$_POST['postcode']; $suburb=$_POST['suburb']; $sex=$_POST['sex']; $city=$_POST['city']; $Country=$_POST['Country']; $age=$_POST['age']; $state=$_POST['state']; /* we are now encrypting password while using md5() function */ $password=md5($pass); $confirm_password=$_POST['confirm_password']; /* Now we will check if username is already in use or not */ $queryuser=mysql_query("SELECT * FROM users WHERE username='$username' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { echo "Sorry, ".$username." is already been taken."; } else { /* Now we will check if username is already in use or not */ $queryuser=mysql_query("SELECT * FROM users WHERE email='$email' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { echo "Sorry, ".$email." has already been taken."; } else { /* now we will check if password and confirm password matched */ if($pass != $confirm_password) { echo "Password and confirm password fields were not matched"; } else { if($age < "18") { echo "you must be 18 years or older to join"; } else { if($email = "") { echo "you must enter an email address"; } else { if($postcode == "") { echo "you must your postcode"; } else { if($city == "") { echo "you must enter your city"; } else { if($suburb == "") { echo "you must enter your suburb"; } else { if($state == "") { echo "you must enter your state"; } else { /* Now we will write a query to insert user details into database */ $insert_user=mysql_query("INSERT INTO users (state, age, city, Country, username, password, email, postcode, suburb, sex) VALUES ('$state','$age', '$city', '$Country' , '$username', '$password', '$email', '$postcode', '$suburb', '$sex') "); if($insert_user) { header("location:signupnow.php"); die();} else { { echo "error in registration".mysql_error(); } } /* closing the if else statements */ }}}}}}}}} ?> <body> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251691 Share on other sites More sharing options...
conan318 Posted August 4, 2011 Author Share Posted August 4, 2011 it seems to be working but now the email check is saying that the email address is taken no matter what i put in. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; " /> <title>Untitled Document</title> </head> <?php /* This code will make a connection with database */ mysql_connect("localhost", "admin", "admin")or die("cannot connect"); mysql_select_db("main")or die("cannot select DB"); /* Now we will store the values submitted by form in variable */ $username=$_POST['username']; $pass=$_POST['password']; $email=$_POST['email']; $postcode=$_POST['postcode']; $suburb=$_POST['suburb']; $sex=$_POST['sex']; $city=$_POST['city']; $Country=$_POST['Country']; $age=$_POST['age']; $state=$_POST['state']; /* we are now encrypting password while using md5() function */ $password=md5($pass); $confirm_password=$_POST['confirm_password']; /* Now we will check if username is already in use or not */ $queryuser=mysql_query("SELECT * FROM main.users WHERE username='$username' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { echo "Sorry, ".$username." is already been taken."; } else { /* Now we will check if username is already in use or not */ $queryuser=mysql_query("SELECT * FROM main.users WHERE email='$email' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { echo "Sorry, ".$email." has already been taken."; } else { /* now we will check if password and confirm password matched */ if($pass != $confirm_password) { echo "Password and confirm password fields were not matched"; } else { if($age < "18") { echo "you must be 18 years or older to join"; } else { if($email = "") { echo "you must enter an email address"; } else { if($postcode == "") { echo "you must your postcode"; } else { if($city == "") { echo "you must enter your city"; } else { if($suburb == "") { echo "you must enter your suburb"; } else { if($state == "") { echo "you must enter your state"; } else { /* Now we will write a query to insert user details into database */ $insert_user=mysql_query("INSERT INTO main.users state, age, city, country, username, password, email, postcode, suburb, sex) VALUES ('$state','$age', '$city', '$Country' , '$username', '$password', '$email', '$postcode', '$suburb', '$sex'") ; if($insert_user) { header("location:signupnow.php"); die();} else { echo "error in registration".mysql_error(); } /* closing the if else statements */ }}}}}}}}} ?> <body> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251696 Share on other sites More sharing options...
phpSensei Posted August 4, 2011 Share Posted August 4, 2011 You keep making more typos. INSERT INTO main.users state, For the email, print this out $checkuser=mysql_num_rows($queryuser); Quote Link to comment https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251697 Share on other sites More sharing options...
conan318 Posted August 4, 2011 Author Share Posted August 4, 2011 $insert_user=mysql_query("INSERT INTO main.users (state, age, city, country, username, password, email, postcode, suburb, sex) VALUES ('$state','$age', '$city', '$Country' , '$username', '$password', '$email', '$postcode', '$suburb', '$sex')") ; fixed cheers mate Quote Link to comment https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251698 Share on other sites More sharing options...
phpSensei Posted August 4, 2011 Share Posted August 4, 2011 Np Glad to help, how's the email problem though? Quote Link to comment https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251700 Share on other sites More sharing options...
conan318 Posted August 4, 2011 Author Share Posted August 4, 2011 it all working expect for its not inserting email value into the database for some silly reason. i have it set up a varchar and latin1_swedish_ci not sure if that's right tho it just defaulted to that setting Quote Link to comment https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251722 Share on other sites More sharing options...
conan318 Posted August 4, 2011 Author Share Posted August 4, 2011 will not insert the email into the database plz help everything else inserts fine <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <? session_start(); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; " /> <title>Sign up now</title> <link href="css/main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> <!-- function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } //--> </script> </head> <body> <div class="content"> <div class="header"> <img src="banner.png" /> </div> <div class="signup"> <form method="post" action="signup.php" enctype="multipart/form-data"> Sign up and create profile<br /> <br /> <label for="username">Username:</label> <input type="text" name="username" /><br /> <label for="Password">Password:</label> <input type="password" name="password" /><br /> <label for="Confirm Password">Confirm Password:</label> <input type="password" name="confirm_password" /><br /> <label for="email">Email:</label> <input type="text" name="email" /><br /> <label for="age">Age:</label> <input type="text" name="age" /> <br /> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; " /> <title>Untitled Document</title> </head> <?php /* This code will make a connection with database */ mysql_connect("localhost", "admin", "admin")or die("cannot connect"); mysql_select_db("main")or die("cannot select DB"); /* Now we will store the values submitted by form in variable */ $username=$_POST['username']; $pass=$_POST['password']; $email=$_POST['email']; $postcode=$_POST['postcode']; $suburb=$_POST['suburb']; $sex=$_POST['sex']; $city=$_POST['city']; $Country=$_POST['Country']; $age=$_POST['age']; $state=$_POST['state']; /* we are now encrypting password while using md5() function */ $password=md5($pass); $confirm_password=$_POST['confirm_password']; /* Now we will check if username is already in use or not */ $queryuser=mysql_query("SELECT * FROM main.users WHERE username='$username' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { echo "Sorry, ".$username." is already been taken."; } else { /* Now we will check if email is already in use or not */ $queryuser=mysql_query("SELECT * FROM main.users WHERE email='$email' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { echo "Sorry, ".$email." has already been taken."; } else { /* now we will check if password and confirm password matched */ if($pass != $confirm_password) { echo "Password and confirm password fields were not matched"; } else { if($age < "18") { echo "you must be 18 years or older to join"; } else { if($email = "") { echo "you must enter an email address"; } else { if($postcode == "") { echo "you must your postcode"; } else { if($city == "") { echo "you must enter your city"; } else { if($suburb == "") { echo "you must enter your suburb"; } else { if($state == "") { echo "you must enter your state"; } else { /* Now we will write a query to insert user details into database */ $insert_user=mysql_query("INSERT INTO main.users (state, age, city, country, username, password, email, postcode, suburb, sex) VALUES ('$state','$age', '$city', '$Country' , '$username', '$password', '$email', '$postcode', '$suburb', '$sex')") ; } if($insert_user) { header("location:signupnow.php"); die();} else { echo "error in registration".mysql_error(); } /* closing the if else statements */ }}}}}}}} ?> <body> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251761 Share on other sites More sharing options...
Muddy_Funster Posted August 4, 2011 Share Posted August 4, 2011 if($email = "") { echo "you must enter an email address"; } else { you missed out an = in the if. single = assignes the value on the right to the value on the left, double == compaires value on left to value on right. I do it all the time Quote Link to comment https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251773 Share on other sites More sharing options...
conan318 Posted August 4, 2011 Author Share Posted August 4, 2011 ahhhh i cant belive i did that again lol thanks Quote Link to comment https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251802 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.