Jump to content

SQL syntax error

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Timefly

Timefly

    Newbie

  • Members
  • Pip
  • 2 posts
I keep getting this error:
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 'Company, email, address1, address2, address3, address4, pcode, phone, mphone, en' at line 1

From this line of code:
$query = "INSERT INTO clients ( first_name, second_name, position_title, business_name, business_type, email_address, address_line_1, address_line_2, address_line_3, address_line_4, post_code, telephone, mobile_telephone, enquiry, contact_by, newsletter, salutation ) values ( ".$_POST['fname'].$gap.$_POST['sname'].$gap.$_POST['pos'].$gap.$_POST['bname'].$gap.$_POST['btype'].$gap.$_POST['email'].$gap.$_POST['address1'].$gap.$_POST['address2'].$gap.$_POST['address3'].$gap.$_POST['address4'].$gap.$_POST['pcode'].$gap.$_POST['telephone'].$gap.$_POST['mtelephone'].$gap.$_POST['enquiry'].$gap.$_POST['contact'].$gap.$_POST['nletter'].$gap.$_POST['salut']." )";

Any help, please?

Oh and
$gap = ", ";


#2
udaymishra

udaymishra

    Newbie

  • Members
  • Pip
  • 2 posts
Are you sure you get all Post variables to this page. If you are missing any one variable your sql will read ",,".
Please implement a check.

To help you further, please use
echo $query
to see what exactly the sql query turn out to be.

#3
Timefly

Timefly

    Newbie

  • Members
  • Pip
  • 2 posts
Thanks, I echoed it and realised i'd left out all the ' marks. Thanks.