SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL Syntax Error, Need Help!

    ok here is the basic of what I have:

    I have a form
    https://stronghold.your-site.com/ove...nline5man.html

    This form points to a php page, below is the php page:

    PHP Code:
    <?php 
    $connection 
    mysql_connect("io2.your-site.com","username","password" ); 
    $db mysql_select_db("overlook"$connection); 

    $sql "INSERT INTO Players (FirstName1, LastName1, Email1, DOB1, Height1, Address1, City1, State1, Zip1, Phone1, Skill1, TShirt1, PlayerSig1, ParentSig1, FirstName2, LastName2, Email2, DOB2, Height2, Address2, City2, State2, Zip2, Phone2, Skill2, TShirt2, PlayerSig2, ParentSig2, FirstName3, LastName3, Email3, DOB3, Height3, Address3, City3, State3, Zip3, Phone3, Skill3, TShirt3, PlayerSig3, ParentSig3, FirstName4, LastName4, Email4, DOB4, Height4, Address4, City4, State4, Zip4, Phone4, Skill4, TShirt4, PlayerSig4, ParentSig4, TeamName) VALUES ('$FirstName1', '$LastName1', '$Email1', '$DOB1', '$Height'1, '$Address1', '$City1', '$State1', '$Zip1', '$Phone1', '$Skill1', '$TShirt1', '$PlayerSig1', '$ParentSig1', '$FirstName2', '$LastName2', '$Email2', '$DOB2', '$Height2', '$Address2', '$City2', '$State2', '$Zip2', '$Phone2', '$Skill2', '$TShirt2', '$PlayerSig2', '$ParentSig2', '$FirstName3', '$LastName3', '$Email3', '$DOB3', '$Height3', '$Address3', '$City3', '$State3', '$Zip3', '$Phone3', '$Skill3', '$TShirt3', '$PlayerSig3', '$ParentSig3'
    , '
    $FirstName4', '$LastName4', '$Email4', '$DOB4', '$Height4', '$Address4', '$City4', '$State4', '$Zip4', '$Phone4', '$Skill4', '$TShirt4', '$PlayerSig4', '$ParentSig4'
    , '
    $TeamName')"


    //all the variables come from the form that was submitted to this script 

    $sql_result mysql_query($sql,$connection) OR die("Couldn't insert the players into the table, here's why:" mysql_error());   

    //Now if you wanted, you could send them to that payment page 
    header("Location: http://www.olclothing.com" ); 
    ?>
    When I submit my form with made up information I get the following message:

    Couldn't insert the players into the table, here's why: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 '1, '123 Easy St', 'Gainesville', 'FL', '32607', '352-555-5555',[
    I'm assuming there is a problem with my table in mysql. I posted the php above just incase. The problem seems to be with fields that use letters, numbers, and symbols. Fields like phone # 555-555-5555. I have everything set to varchar which is the default, should I change this other fields to something else? If so what?

    Thanks

    Merlow

  2. #2
    SitePoint Wizard Chris82's Avatar
    Join Date
    Mar 2002
    Location
    Osnabrück
    Posts
    1,003
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have the "1" of "height1" outside the enclosing single quotes:

    PHP Code:
    $sql "INSERT INTO Players (FirstName1, LastName1, Email1, DOB1, Height1, Address1, City1, State1, Zip1, Phone1, Skill1, TShirt1, PlayerSig1, ParentSig1, FirstName2, LastName2, Email2, DOB2, Height2, Address2, City2, State2, Zip2, Phone2, Skill2, TShirt2, PlayerSig2, ParentSig2, FirstName3, LastName3, Email3, DOB3, Height3, Address3, City3, State3, Zip3, Phone3, Skill3, TShirt3, PlayerSig3, ParentSig3, FirstName4, LastName4, Email4, DOB4, Height4, Address4, City4, State4, Zip4, Phone4, Skill4, TShirt4, PlayerSig4, ParentSig4, TeamName) VALUES ('$FirstName1', '$LastName1', '$Email1', '$DOB1', '$Height1', '$Address1', '$City1', '$State1', '$Zip1', '$Phone1', '$Skill1', '$TShirt1', '$PlayerSig1', '$ParentSig1', '$FirstName2', '$LastName2', '$Email2', '$DOB2', '$Height2', '$Address2', '$City2', '$State2', '$Zip2', '$Phone2', '$Skill2', '$TShirt2', '$PlayerSig2', '$ParentSig2', '$FirstName3', '$LastName3', '$Email3', '$DOB3', '$Height3', '$Address3', '$City3', '$State3', '$Zip3', '$Phone3', '$Skill3', '$TShirt3', '$PlayerSig3', '$ParentSig3'
    , '
    $FirstName4', '$LastName4', '$Email4', '$DOB4', '$Height4', '$Address4', '$City4', '$State4', '$Zip4', '$Phone4', '$Skill4', '$TShirt4', '$PlayerSig4', '$ParentSig4'
    , '
    $TeamName')"

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Chris82
    You have the "1" of "height1" outside the enclosing single quotes:

    PHP Code:
    $sql "INSERT INTO Players (FirstName1, LastName1, Email1, DOB1, Height1, Address1, City1, State1, Zip1, Phone1, Skill1, TShirt1, PlayerSig1, ParentSig1, FirstName2, LastName2, Email2, DOB2, Height2, Address2, City2, State2, Zip2, Phone2, Skill2, TShirt2, PlayerSig2, ParentSig2, FirstName3, LastName3, Email3, DOB3, Height3, Address3, City3, State3, Zip3, Phone3, Skill3, TShirt3, PlayerSig3, ParentSig3, FirstName4, LastName4, Email4, DOB4, Height4, Address4, City4, State4, Zip4, Phone4, Skill4, TShirt4, PlayerSig4, ParentSig4, TeamName) VALUES ('$FirstName1', '$LastName1', '$Email1', '$DOB1', '$Height1', '$Address1', '$City1', '$State1', '$Zip1', '$Phone1', '$Skill1', '$TShirt1', '$PlayerSig1', '$ParentSig1', '$FirstName2', '$LastName2', '$Email2', '$DOB2', '$Height2', '$Address2', '$City2', '$State2', '$Zip2', '$Phone2', '$Skill2', '$TShirt2', '$PlayerSig2', '$ParentSig2', '$FirstName3', '$LastName3', '$Email3', '$DOB3', '$Height3', '$Address3', '$City3', '$State3', '$Zip3', '$Phone3', '$Skill3', '$TShirt3', '$PlayerSig3', '$ParentSig3'
    , '
    $FirstName4', '$LastName4', '$Email4', '$DOB4', '$Height4', '$Address4', '$City4', '$State4', '$Zip4', '$Phone4', '$Skill4', '$TShirt4', '$PlayerSig4', '$ParentSig4'
    , '
    $TeamName')"
    Guess I stared to long

    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
  •