dreamweaver / mysql / php - 表名不正确

时间:2016-04-23 10:15:13

标签: php mysql dreamweaver

对不起,我真的非常真的很新的php / mysql / dreamweaver。我尝试将我的order.php链接到数据库,当我在服务器上打开然后点击sumbit时,表格名称不正确""'有人可以帮助我

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "order")) {
  $insertSQL = sprintf("INSERT INTO ``order`` (Username, Name, Email, Address, PhoneNumber, `Size`, OrderItem, Quantity) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Username'], "text"),
                       GetSQLValueString($_POST['Name'], "text"),
                       GetSQLValueString($_POST['Email'], "text"),
                       GetSQLValueString($_POST['Address'], "text"),
                       GetSQLValueString($_POST['PhoneNumber'], "int"),
                       GetSQLValueString($_POST['Size'], "int"),
                       GetSQLValueString($_POST['OrderItem'], "text"),
                       GetSQLValueString($_POST['Quantity'], "text"));

  mysql_select_db($database_Assignment2, $Assignment2);
  $Result1 = mysql_query($insertSQL, $Assignment2) or die(mysql_error());
}

4 个答案:

答案 0 :(得分:0)

$insertSQL = sprintf("INSERT INTO `order` (Username, Name, Email, Address, PhoneNumber, `Size`, OrderItem, Quantity) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Username'], "text"),
                       GetSQLValueString($_POST['Name'], "text"),
                       GetSQLValueString($_POST['Email'], "text"),
                       GetSQLValueString($_POST['Address'], "text"),
                       GetSQLValueString($_POST['PhoneNumber'], "int"),
                       GetSQLValueString($_POST['Size'], "int"),
                       GetSQLValueString($_POST['OrderItem'], "text"),
                       GetSQLValueString($_POST['Quantity'], "text"));

请尝试此

答案 1 :(得分:0)

在您的查询$insertSQL = sprintf("INSERT INTO ``order`` (Username中进行更正$insertSQL = sprintf("INSERT INTO订单(Username

答案 2 :(得分:0)

代替此:

插入order

您需要这样做:

插入order

答案 3 :(得分:-1)

而不是:

INSERT INTO ``order``

你需要这样做:

INSERT INTO `order`