SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    May 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    You have an error in your SQL syntax

    I am getting this error on my results page for a form:

    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 'references, insurance, namedate) VALUES ('test','test','test','t

    This is my code:

    Code:
     <?php
    $con = mysql_connect("mysql","*****","*****");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }mysql_select_db("dasher", $con);$sql="INSERT INTO vendor (cname, maddress, paddress, supplies, bphone, cphone, fax, email, conname, capacity, contactcellphone, statetax, fedtax, ssn, lengthbusiness, license, residence, references, insurance, namedate)
    VALUES
    ('$_POST[cname]','$_POST[maddress]','$_POST[paddress]','$_POST[supplies]','$_POST[bphone]','$_POST[cphone]','$_POST[fax]','$_POST[email]','$_POST[conname]','$_POST[capacity]','$_POST[contactcellphone]','$_POST[statetax]','$_POST[fedtax]','$_POST[ssn]','$_POST[lengthbusiness]','$_POST[license]','$_POST[residence]','$_POST[references]','$_POST[insurance]','$_POST[namedate]')";if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "Your application is being reviewed.";mysql_close($con)
    ?>
    I'm not seeing any problems. Am I missing something?

    Thanks!

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,169
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    "references" is a reserved word. You'll need to change that or put it in backticks.

  3. #3
    SitePoint Member
    Join Date
    May 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That was it! Thanks man! I have another question. Would it be possible to export the table into an organized form so that it isn't just rows of data? This would be so my client can easily look over the information submitted.

  4. #4
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how is rows of data not organized already? You'd have to clarify what you want your client to look at for us to decide how to answer that question.

  5. #5
    SitePoint Member
    Join Date
    May 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I'm talking about is a proper form like you would have on a print out. My client gave me a print out of their form, and I made a form on the website. So could they be able to see an export that looks similar to their form that's on paper? So that they maybe could print that out.

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,169
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    You can export database content in a few formats, but they are for backing up or moving, not really for human consumption, unless maybe if you like reading raw CSV

    What you want is to put together a SELECT query to get what you want and have some sort of script format it.

    Although MySQL can allow for some fine tuning, it really depends mostly on what language you're working with.

  7. #7
    SitePoint Member
    Join Date
    May 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll give that a shot. Thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •