php runs, database doesn't accept.

Discussion in 'MySQL' started by Matt Ridge, Nov 3, 2011.

  1. #1
    Here is the code:

    
    <!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">
    
    
    
    
    <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
     
       //Check if variable is empty
              if(empty($NCMR_ID)){
                die ("<p>Added By Field is Empty</p>");
              }
    
    
      $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_PD', '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));
    }
    	//If there are no errors.
              else {            
                //Put all of your MySQL crap here.
                echo '<p>Form succesfully submitted</p>';
    	}	
      mysqli_close($dbc);
    	
      ?>
    
    
    
    
    </body>
    </html>
    Code (markup):
    The problem is my code works, the database seems to not accept the results. Well lets rephrase that, it accepts the code, but only posts the dates, when before it posted everything.

    Can someone give me an idea of what is going on?
     
    Matt Ridge, Nov 3, 2011 IP
  2. Valdor

    Valdor Well-Known Member

    Messages:
    450
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Have you changed server? have you changed anything else in the other parts of the site that pass the data to this script? Has the hosting provider updated php or mysql?

    have you made sure the data is there to be added by using a echo statements so you can check.
     
    Valdor, Nov 3, 2011 IP
  3. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #3
    No, after hounding my hosting service, I got an answer of why this was not working, and it was simple... they stopped some global scripts from working. Once I got the .htaccess file added in with the right scripts, everything worked. Regretfully they won't let the globals I need be used in general but its better than nothing.
     
    Matt Ridge, Nov 7, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    Check what your code does.
    At this point, since you haven't even created $NCMR_ID, let alone put anything into it, your script ends.

    All that happens (or would happen, but doesn't) after you check $NCMR_ID and find it empty. Learn to use FirePHP so you can see what's happening as your script runs.
     
    Rukbat, Nov 15, 2011 IP