douyejv820598
2016-04-23 10:15
浏览 99
已采纳

dreamweaver / mysql / php - 表名不正确

Im sorry but i really really really new to php/mysql/dreamweaver. i try to link my order.php to database and when i open on the server then click sumbit, there is 'incorrect table name ""' can someone help me

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条回答 默认 最新

  • douruhu4282 2016-04-23 10:25
    已采纳

    Instead of this:

    INSERT INTO ``order``
    

    You need to do:

    INSERT INTO `order`
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dou12754 2016-04-23 10:20
    $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"));
    

    Please try this

    评论
    解决 无用
    打赏 举报
  • dtxa49711 2016-04-23 10:25

    Make correction in your query $insertSQL = sprintf("INSERT INTO ``order`` (Username like this $insertSQL = sprintf("INSERT INTOorder(Username

    评论
    解决 无用
    打赏 举报
  • doujing6053 2019-02-19 06:39

    Instead of this:

    INSERT INTO order

    You need to do:

    INSERT INTO order

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题