Search code examples
phpmysqldreamweaver

dreamweaver/mysql/php - incorrect table name


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());
}

Solution

  • Instead of this:

    INSERT INTO ``order``
    

    You need to do:

    INSERT INTO `order`