Hi all,
was wondering if I could get some help with my code. I want to be able to insert a person and details into a database, however i keep getting a syntax error, and not very experienced so was hoping some one here could help. thanks


// Replace the variable values below
// with your specific database information.
$host = "localhost";
$user = "root";
$pass = "";
$db   = "users";

// This part sets up the connection to the 
// database (so you don't need to reopen the connection
// again on the same page).
$conn = mysql_connect ($host, $user, $pass);
//$ms = mysql_pconnect($host, $user, $pass);
if (!$conn)
//if ( !$ms )
echo "Error connecting to database.\n";

// Then you need to make sure the database you want
// is selected.


// dBase file
include 'dbConfig.php';

$Name = $_POST['inputName'];
$Surname = $_POST['inputSurname'];
$PhoneNo = $_POST['inputPhoneNo'];
$Email = $_POST['inputEmail'];
$Cemail = $_POST['inputCemail'];
$Username = $_POST['inputUsername'];
$Password = $_POST['inputPassword'];
$Cpassword = $_POST['inputCpassword'];

if (!$_POST['submit']) { 
	echo "Please complete all this form";
	header ('Location: registernow.php');
}else {

	mysql_query ("INSERT INTO members('ID','Name','Surname','Phone','Email','Cemail','Username','Password','Cpassword')
	VALUES (NULL, '$Name','$Surname','$PhoneNo','$Email','$Cemail','$Username','$Password','$Cpassword'") or die (mysql_error());

echo "User Has Been Successfully Added";
header ('Location: registernow.php');



// dBase file
include 'dbConfig.php';

echo "connection successful";	

<form action = "create.php" method="post">

<p>Name: <br/><input type="text" name = "inputName" value="" /></p>
<p>Surname: <br/><input type="text" name = "inputSurname" value="" /></p>
<p>Phone No: <br/><input type="text" name = "inputPhoneNo" value="" /></p>
<p>Email Address: <br/><input type="text" name = "inputEmail" value="" /></p>
<p>Confirm Email Address: <br/><input type="text" name = "inputCemail" value="" /></p>
<p>Username: <br/><input type="text" name = "inputUsername" value="" /></p>
<p>Password: <br/><input type="text" name = "inputPassword" value="" /></p>
<p>Confirm Password: <br/><input type="text" name = "inputCpassword" value="" /></p>

<input type = "submit" name="submit" />
<input type="reset" name="Clear" />

6 Years
Discussion Span
Last Post by lovell_82

What syntax error do you get? I assune it's because the column names in your query are bracketed in apostrophes, which the should not be. Try instead:

mysql_query ("INSERT INTO members(ID,Name,Surname,Phone,Email,Cemail,Username,Password,Cpassword)
	VALUES (NULL, '$Name','$Surname','$PhoneNo','$Email','$Cemail','$Username','$Password','$Cpassword'") or die (mysql_error());

That was it, thank you so much. New to this, not very much experience.
Cheers for fast reply

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.