SQL to Database, not exactly working correctly...

Discussion in 'Databases' started by Matt Ridge, Sep 22, 2011.

  1. #1
    This code gets an error when I attempt to post data...

    http://www.kaboomlabs.com/PDI/ncmr.html

    The Error is:

    Now I have in the database, where the dates are going to be used fields showing DATE as its only input, so I am lost trying to figure out what is going on.

    I have been working on the PHP code in the PHP section, but I figured that since SQL is squawking at me, I may be able to get an answer here upon why...

    Thanks in advance.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>PDI Non-Conforming Materials Report </title>
    </head>
    
    
    <body>
      <h2>PDI Non-Conforming Materials Report</h2>
    
    
    <?php
      $Added_By = $_POST['Added_By'];
      $Added_By_Date = date('Y-m-d',strtotime($_POST['Added_By_Date']));
      $Nexx_Part = $_POST['Nexx_Part'];
      $Nexx_Rev = $_POST['Nexx_Rev'];
      $Nexx_Part_Description = $_POST['Nexx_Part_Description'];
      $NCMR_Qty = $_POST['NCMR_Qty'];
      $JO = $_POST['JO'];
      $SN = $_POST['SN'];
      $INV = $_POST['INV'];
      $Nexx_Inventory_On_Hand = $_POST['Nexx_Inventory_On_Hand'];
      $Nexx_Inventory_Chk = $_POST['Nexx_Inventory_Chk'];
      $Supplier_Name = $_POST['Supplier_Name'];
      $Supplier_Number = $_POST['Supplier_Number'];
      $Manufacturer_Part_Number = $_POST['Manufacturer_Part_Number'];
      $Manufacturer_Serial_Number = $_POST['Manufacturer_Serial_Number'];
      $NCMR_ID = $_POST['NCMR_ID'];
      $Nonconformity = $_POST['Nonconformity'];
      $Disposition = $_POST['Disposition'];
      $Comments = $_POST['Comments'];
      $CommentsAdditional_Details = $_POST['CommentsAdditional_Details'];
      $PO = $_POST['PO'];
      $PO_Date = date('Y-m-d',strtotime($_POST['PO_Date']));
      $Date_Received = date('Y-m-d',strtotime($_POST['Date_Received']));
    
    
      $dbc = mysqli_connect('localhost', 'pawz_PDI', 'pdi1234', 'pawz_PDI')
        or die('Error connecting to MySQL server.');
    
    
      $query= "INSERT INTO ncmrtest (Added_By, Added_By_Date, Nexx_Part, Nexx_Rev, Nexx_Part_Description, NCMR_Qty, JO, SN, INV, Nexx_Inventory_On_Hand, Nexx_Inventory_Chk, Supplier_Name, Supplier_Number, Manufacturer_Part_Number, Manufacturer_Serial_Number, NCMR_ID, Nonconformity, Disposition, Comments, CommentsAdditional_Details, PO, PO_Date, Date_Received) 
      
      values('$Added_By', '$Added_By_Date', '$Nexx_Part', '$Nexx_Rev', '$Nexx_Part_Description', '$NCMR_Qty', '$JO', '$SN', '$INV', '$Nexx_Inventory_On_Hand', '$Nexx_Inventory_Chk', '$Supplier_Name', '$Supplier_Number', '$Manufacturer_Part_Number', '$Manufacturer_Serial_Number', '$NCMR_ID', '$Nonconformity', '$Disposition', '$Comments', '$CommentsAdditional_Details', $PO'', '$PO_Date', '$Date_Received')"; 
    
    
      if (!$result = mysqli_query($dbc, $query)) 
      {
      printf("Error message: %s\n", mysqli_error($dbc));
    }
    
    
      mysqli_close($dbc);
    
    
      echo 'Thanks for submitting the form. The information has been entered and will be reviewed by the correct personnel.<br />';
      ?>
    
    
    </body>
    </html>
    Code (markup):
     
    Matt Ridge, Sep 22, 2011 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Problem is in last line of query:

    
    CommentsAdditional_Details', [B]$PO[COLOR="#FF0000"]''[/COLOR][/B], '$PO_Date', '$Date_Received')";
    
    Code (markup):
    should be

    
    CommentsAdditional_Details', [B]'$PO'[/B], '$PO_Date', '$Date_Received')";
    
    Code (markup):
     
    mastermunj, Sep 23, 2011 IP