Syntax error using email as field

Links for php scripts

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 3
Joined: Tue Apr 09, 2013 1:08 am

Syntax error using email as field

Postby jimdac59 » Fri Apr 12, 2013 5:00 am

Hi all
I do hope you can help
I am creating a new user using the email as the username field. all is going okay except for a syntax error from Mysql
The error reads like this:
You have an error in your MySQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') values ( '' at line 2

and Here is the code

<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>

if (isset($_POST['submit'])) { // Form has been submitted.

// perform validations on the form data
$required_fields = array('Email', 'password','FirstName', 'LastName', 'Permission', 'Location');
$errors = array_merge($errors, check_required_fields($required_fields, $_POST));

$fields_with_lenghts= array('Email' =>80, 'password' => 50, 'Permission' =>20, 'Location' =>30,
'FirstName'=>50, 'LastName' =>60 );
$errors = array_merge($errors, check_max_field_lengths($fields_with_lenghts, $_POST));

// Username is email address
$hashed_password = sha1($password);

if (empty($errors)){
$query = "INSERT INTO cssu(
Email, hashed_password, Location, FirstName, LastName, Permission,)
values (
'{$email}', '{$hashed_password}', '{$location}', '{$firstname}', '{$lastname}', '{$permission}')";

$result = mysql_query($query, $connection);
if ($result){
$message = "The User was successfully Created.";
}else {
$message ="The user could not be created";
$message .="</br> />" . mysql_error();
}else {

if (count($errors)==1){
$message ="There was 1 error in the form";

} else {
$message = "There were " . count($errors) . "errors in the form";

} else { // Form has not been submitted. Username is email address
$email = "";
$password = "";
$location = "";
$firstname ="";
$lastname = "";
$permission = "";


Can anyone please help

Jim :(

New php-forum User
New php-forum User
Posts: 44
Joined: Tue May 28, 2013 10:04 pm
Location: India,Lucknow

Re: Syntax error using email as field

Postby developerahusain » Tue May 28, 2013 10:17 pm

Hi Jim

Your insert query looks bit fussier. Even i'm not able to find out syntax error.
you use this mysql query which is short and easy to use. You edit this query and modify it as you want

if(mysql_query("insert into f0001_name(mn,en,Title,Fullname,Fname,Lname,Mname,Oname) values ('"
.$_SESSION['mn']."','".$_SESSION['en']."','".$titel."','".$_POST['txtfullname']."','".$_POST['txtfirstname']."','".$_POST['txtlastname']."','".$_POST['txtmiddlename']."','".$_POST['txtothername']."')") or die("the eror ".mysql_error()))


Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests