SQL语法错误 - 检查手册

时间:2013-02-16 09:30:11

标签: php sql

        <?php     function createLead($CuFirst, $CuLast, $COBool, $COFirst, $COLast, $CuAddrs1,
    $CuAddrs2, $CuCity, $CuZip, $CuEmail, $CuDphone, $CuHphone, $CuCphone, $BuildYr, $HoAge, $NoWindows,
    $NoWindowQuote, $WindowType1, $WindowType2, $WindowType3, $WindowType4, $GlassType1, $GlassType2,
    $Doors1, $Doors2, $Doors3, $Doors4, $Issue1, $Issue2, $Issue3, $Issue4, $Issue5, $Issue6, $Issue6,
    $Issue7, $Event, $Staff, $DigiSign, $Comments) {
        $CreateLead = "INSERT INTO  'rbaevent'.'leadentry' ('CuLast','CuFirst','COBool','COFirst','COLast','CuAddrs1','CuAddrs2','City','Zip','Email',
'DPhone','HPhone','CPhone','Built','AgeWindows','NoWindows','NoWinQuote','Aluminium','Vinyl',
'Wood','Clad','Single','Double','Entry','Patio','French','None','Cost','Cold','Clean',
'Fogging','Hard','Rotting','Peeling','Secure','Event','selectname','DigiSign','Comments')
 VALUES ('$CuFirst', '$CuLast','$COBool', '$COFirst', '$COLast', '$CuAddrs1', '$CuAddrs2',
'$CuCity', '$CuZip', '$CuEmail','$CuDphone', '$CuHphone', '$CuCphone', '$BuildYr', '$HoAge',
'$NoWindows', '$NoWindowQuote','$WindowType1', '$WindowType2', '$WindowType3', '$WindowType4',
'$GlassType1', '$GlassType2','$Doors1', '$Doors2', '$Doors3', '$Doors4', '$Issue1', '$Issue2',
'$Issue3', '$Issue4', '$Issue5','$Issue6', '$Issue6', '$Issue7',  '$Event', '$Staff',
'$DigiSign' ,'$Comments')";
         return $CreateLead; }

以下是错误消息:

您的SQL语法出错;检查与MySQL服务器版本相对应的手册,以便在''leadentry'('CuLast','CuFirst','COBool','COFirst','COLast','CuAddrs1','CuA'附近使用正确的语法)第1行

2 个答案:

答案 0 :(得分:3)

在SQL查询中指向表时,不能使用这些引号

INTO  'rbaevent'.'leadentry' (

应该是

INTO  `rbaevent`.`leadentry` (

答案 1 :(得分:1)

将您的代码更改为: 你使用了错误的''你必须使用``在键盘上的TAB按钮上面

  function createLead($CuFirst, $CuLast, $COBool, $COFirst, $COLast, $CuAddrs1,     $CuAddrs2, $CuCity, $CuZip, $CuEmail, $CuDphone, $CuHphone, $CuCphone, $BuildYr, $HoAge, $NoWindows, $NoWindowQuote, $WindowType1, $WindowType2, $WindowType3, $WindowType4, $GlassType1, $GlassType2, $Doors1, $Doors2, $Doors3, $Doors4, $Issue1, $Issue2, $Issue3, $Issue4, $Issue5, $Issue6, $Issue6, $Issue7, $Event, $Staff, $DigiSign, $Comments) {
     $CreateLead = "INSERT INTO  `rbaevent`.`leadentry` (
      `CuLast`,
      `CuFirst`,
      `COBool`,
      `COFirst`,
      `COLast`,
      `CuAddrs1`,
      `CuAddrs2`,
      `City`,
      `Zip`,
      `Email`,
      `DPhone`,
      `HPhone`,
      `CPhone`,
      `Built`,
      `AgeWindows`,
      `NoWindows`,
      `NoWinQuote`,
      `Aluminium`,
      `Vinyl`,
      `Wood`,
      `Clad`,
      `Single`,
      `Double`,
      `Entry`,
      `Patio`,
      `French`,
      `None`,
      `Cost`,
      `Cold`,
      `Clean`,
      `Fogging`,
      `Hard`,
      `Rotting`,
      `Peeling`,
      `Secure`, 
      `Event`, 
      `selectname`,
      `DigiSign`,
       `Comments`)
    VALUES ('$CuFirst', '$CuLast', '$COBool', '$COFirst', '$COLast', '$CuAddrs1', '$CuAddrs2', '$CuCity', '$CuZip', '$CuEmail', '$CuDphone', '$CuHphone', '$CuCphone', '$BuildYr', '$HoAge', '$NoWindows', '$NoWindowQuote', '$WindowType1', '$WindowType2', '$WindowType3', '$WindowType4', '$GlassType1', '$GlassType2', '$Doors1', '$Doors2', '$Doors3', '$Doors4', '$Issue1', '$Issue2', '$Issue3', '$Issue4', '$Issue5', '$Issue6', '$Issue6', '$Issue7',  '$Event', '$Staff', '$DigiSign' ,'$Comments')";
  return $CreateLead;
 }

就是这样!