Jump to content

wamp server


conan318

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/243779-wamp-server/
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251691
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251696
Share on other sites

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>



Link to comment
https://forums.phpfreaks.com/topic/243779-wamp-server/#findComment-1251761
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.