SQL数据库未更新,收到错误消息,新手不确定原因


SQL Data Base not updating getting error message, Newbie not sure why?

嗨,这是我下面的代码,当按下提交按钮时,我收到一条错误消息"您的SQL语法有错误;请查看与MySQL服务器版本相对应的手册,在第7行的'WHERE ID='附近使用正确的语法"无法找出错误!?你能给我建议并帮助我认识到我的错误吗?

    <?php 
include 'connection.php';
if(!isset($_POST['submit'])) {
$q = "SELECT * FROM suppliers WHERE ID = $_GET[id]";
$results = mysql_query ($q);
$person = mysql_fetch_array($results);
}
if(isset($_POST['submit'])) {
    $u = "UPDATE suppliers SET 
                                `supplier_ABE_project_number`='$_POST[supplier_ABE_project_number]',                                                    `supplier_name`='$_POST[supplier_name]',
`supplier_capacity`='$_POST[supplier_capacity]',                                    `supplier_contact`='$_POST[supplier_contact]',
`supplier_email`='$_POST[supplier_email]',                  `supplier_notes`='$_POST[supplier_notes]'
WHERE ID = $_POST[id]";
mysql_query ($u) or die (mysql_error());
}
?>

<style type="text/css"></style>
<link href="styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
    background-color: #F5F6F8;
}
</style>

<table  class="menu_hover" width="100%" border="0" cellspacing="0">
  <tr>
    <td height="104" valign="middle" bgcolor="#FFFFFF"><table width="1000" border="0" align="center" cellspacing="0">
      <tr>
        <td width="184"><a href="dashboard.php"><img src="images/logo.jpg" alt="" width="95" height="90" /></a></td>
        <td width="812" align="right"><table width="0" border="0" cellspacing="0" cellpadding="10">
          <tr class="navi_menu">
            <td width="38" align="center" nowrap="nowrap" class="menu_SECONDARY"><a href="new_project_KYLE.php" class="navi_menu"><img src="images/project_btn.png" alt="" width="139" height="32" /></a></td>
            <td width="77" align="center" nowrap="nowrap" class="menu_SECONDARY"><a href="report.php" class="navi_menu">Reports</a></td>
            <td width="77" align="center" nowrap="nowrap" class="menu_SECONDARY"><a href="dashboard.php" class="navi_menu">Dashboard</a></td>
            <td width="56" align="center" nowrap="nowrap" class="menu_SECONDARY"><a href="logout.php" class="navi_menu">Log Out</a></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="6" align="center" valign="bottom" bgcolor="#FFFFFF"><img src="images/header_line.png" alt="" width="1297" height="4" /></td>
  </tr>
</table>
<table width="100" border="0" align="center" cellpadding="1" cellspacing="0">
  <tr>
    <th height="200" scope="col">&nbsp;</th>
  </tr>
</table>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"  />
<table width="1000" border="0" align="center" cellpadding="10" cellspacing="0" class="corners_white">
  <tr>
    <th width="950" valign="middle" bgcolor="#999999" class="corners" scope="col"><p class="titleWHITE">MODIFY CONTACT</p></th>
  </tr>
  <tr>
    <th valign="middle" bgcolor="#FFFFFF" class="corners" scope="col"><table width="950" border="0" align="center" cellpadding="3" cellspacing="0">
        <tr>
          <th width="77" height="39" align="left" valign="bottom" scope="col"><span class="text">PN</span></th>
          <th width="278" align="left" valign="bottom" scope="col"><span class="text">Name</span></th>
          <th width="144" align="left" valign="bottom" scope="col"><span class="text">Capacity</span></th>
          <th width="193" align="left" valign="bottom" scope="col"><span class="text">Contact</span></th>
          <th width="177" align="left" valign="bottom" scope="col"><span class="text">Email</span></th>
          <th colspan="2" align="left" valign="bottom" scope="col"><span class="text">Notes</span></th>
        </tr>
        <tr>
          <td align="left" valign="middle"><span class="text">
            <input name="supplier_ABE_project_number" type="text" id="supplier_ABE_project_number"  value="<?php echo $person['supplier_ABE_project_number']?>" size="10" />
          </span></td>
          <td align="left" valign="middle"><span class="text">
            <input name="supplier_name" type="text" id="supplier_name" value="<?php echo $person['supplier_name']?>" size="10" />
          </span></td>
          <td align="left" valign="middle"><span class="text">
            <input name="supplier_capacity" type="text" id="supplier_capacity" value="<?php echo $person['supplier_capacity']?>" size="10" />
          </span></td>
          <td align="left" valign="middle"><span class="text">
            <input name="supplier_contact" type="text" id="supplier_contact" value="<?php echo $person['supplier_contact']?>" size="10" />
          </span></td>
          <td align="left" valign="middle"><span class="text">
            <input name="supplier_email" type="text" id="supplier_email" value="<?php echo $person['supplier_email']?>" size="10" />
          </span></td>
          <td width="77" align="left" valign="middle"><span class="text">
            <input name="supplier_notes" type="text" id="supplier_notes" value="<?php echo $person['supplier_notes']?>" size="10" />
          </span></td>
          <td align="left" valign="middle">&nbsp;</td>
        </tr>
      </table>      <p>
        <input name="id" type="hidden" value="<?php echo $_GET['ID']; ?>" />
        <input name="submit" type="submit" class="submit" value="Modify Contact" />
        </form>

    </th>
  </tr>
</table>

在更新查询时,必须用逗号分隔字段:

UPDATE
suppliers
SET 
`supplier_ABE_project_number`='$_POST[supplier_ABE_project_number]',
`supplier_name`='$_POST[supplier_name]',
`supplier_capacity`='$_POST[supplier_capacity]',
`supplier_contact`='$_POST[supplier_contact]',
`supplier_email`='$_POST[supplier_email]',
`supplier_notes`='$_POST[supplier_notes]'       
 WHERE ID = $_POST[id]

附加提示:请逃离您的帖子并获取参数:http://php.net/manual/en/function.mysql-real-escape-string.php