SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2008
    Location
    Philadelphia, PA
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    1064 Error In SQL Syntax

    I have a query, and I'm not sure why I get a syntax error when I try to submit this to the database.
    Code PHP:
    $sql=("INSERT INTO tblapplicant (WholeName, Address, City, State, Zip, Country, Phone, EMail, FellowshipType,
                                    USCitPermRes, Disabled, Disadvantaged, LowIncome, FirstGenColl, Gender, Ethnicity)
          VALUES ($WholeName, $Address, $Address2, $City, $State, $Zip, $Country, $Phone, $Email, $FellowshipType,
                   $USCitPermRes, $Disabled, $Disadvantaged, $LowIncome, $FirstGenColl, $Gender, $Ethnicity)");
     
    if (! mysql_query($sql) ) {
    	warning ("No records added to tblApplicant.");
    }
     
    $sql1=("INSERT INTO tblRace (AppID, IsAmerIndian, IsAsian, IsBlack, IsAPI, IsWhite, IsOther)
          VALUES ($IsAmerIndian, $IsAsian, $IsBlack, $IsAPI, $IsWhite, $IsOther)");
     
    if (! mysql_query($sql1) ) {
    	warning ("No records added to tblRace.");
    }   
    $sql2=("INSERT INTO tbleducation (DegAwarded, UniversityAttended, GPA, Year)
          VALUES ($DegAwarded, $UniversityAttended, $GPA, $Year)");
     
    if (! mysql_query($sql2) ) {
    	warning ("No records added to tblEducation.");
    }
    $sql3=("INSERT INTO tblresearchinterest (ResInt)
          VALUES ($ResInt)");
     
    if (! mysql_query($sql3) ) {
    	warning ("No records added to tblResearchInterest.");
    }
    $sql4=("INSERT INTO tbldocument (Document, DocumentType, DocumentSize, DocumentName)
          VALUES ($Document, $DocumentType, $DocumentSize, $DocumentName)");
     
    if (! mysql_query($sql4) ) {
    	warning ("No records added to tblDocument.");
    }
    $sql5=("INSERT INTO tblexams (ExamType, GREVerbal, GREQuantitative, GREAnalytical, MCATPhysSci, MCATVerbReas, MCATWriting, MCATBioSci, DATNatSci, DATPAT, DATReadComp, DATQuantReas)
          VALUES ($ExamType, $GREVerbal, $GREQuantitative, $GREAnalytical, $MCATPhysSci, $MCATVerbReas, $MCATWriting, $MCATBioSci, $DATNatSci, $DATPAT, $DATReadComp, $DATQuantReas)");
     
    if (! mysql_query($sql5) ) {
    	warning ("No records added to tblExams.");
    }
    $sql6=("INSERT INTO tblthesis (ThesisTitle, Mentor, YearPresented, PriPostDoc, ResExp, ResTrain, ResTrainInst)
          VALUES ($ThesisTitle, $Mentor, $YearPresented, $PriPostDoc, $ResExp, $ResTrain, $ResTrainInst)");
     
    if (! mysql_query($sql6) ) {
    	warning ("No records added to tblThesis.");
    }

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you don't have "a" query, you gots 7 of dem

    which one created the error? can we see the entire error message please?


    Edit: never mind, it's obvious -- you need single quotes around your character string values

    INSERT INTO tblapplicant (WholeName, Address, .... )
    VALUES ('$WholeName', '$Address', ... )

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Dec 2008
    Location
    Philadelphia, PA
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks r937, that worked well. I'm new to this, so I appreciate both your patience and your quick reply.


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
  •