Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

SQL syntax error

syntax syntax error

  • Please log in to reply
2 replies to this topic

#1 Timefly

Timefly

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 02 November 2010 - 03:53 AM

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 = ", ";

  • 0

#2 udaymishra

udaymishra

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 02 November 2010 - 05:21 AM

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.
  • 0

#3 Timefly

Timefly

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 02 November 2010 - 05:30 AM

Thanks, I echoed it and realised i'd left out all the ' marks. Thanks.
  • 0





Also tagged with one or more of these keywords: syntax, syntax error

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download