1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Posting correctly, just not allowing to get correctly...

Discussion in 'PHP' started by Matt Ridge, Feb 20, 2012.

  1. #1
    Ok, for some reason a page that was once working correctly is no longer working, and I've changed nothing on it for over 2 months.

    Here is the error:

    Here is the code, now if you look, at the code, which is long, don't get me wrong... line 104 shows the correct line of code as far as I can tell, and the query is coming back correctly too... so I don't know why this is happening now... Can someone please help me out, it be greatly appreciated. And yes I can use a function, but honestly until I get this working, I am trying to keep the code as short as possible.

    Code (Text):
    1.  
    2. <?php
    3. require_once('../connectvars.php');
    4. echo '<div id="postwrap">'
    5. ?>
    6.  
    7.  
    8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    9.   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    10. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    11. <head>
    12.   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    13.   <title>PDI NCMR - Edit</title>
    14.       <link rel="stylesheet" type="text/css" href="../CSS/postie.css" />
    15. </head>
    16. <body>
    17.    <div id="logo">
    18.     <img src="../images/PDI_Logo_2.1.gif" alt="PDI Logo" />
    19. </div>
    20.  
    21.  
    22. <?php
    23.   if (isset($_POST['submit'])) {
    24. // Connect to the database
    25.     $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    26.    
    27. // Enter data into the database
    28.     $id = mysqli_real_escape_string($dbc, trim($_GET['id']));
    29.     $ab = mysqli_real_escape_string($dbc, trim($_POST['ab']));
    30.     $date = mysqli_real_escape_string($dbc, trim(date('Y-m-d',strtotime ($_POST['date']))));
    31.     $part = mysqli_real_escape_string($dbc, trim($_POST['part']));
    32.     $rev = mysqli_real_escape_string($dbc, trim($_POST['rev']));
    33.     $partdesc = mysqli_real_escape_string($dbc, trim($_POST['partdesc']));
    34.     $ncmrqty = mysqli_real_escape_string($dbc, trim($_POST['ncmrqty']));
    35.     $comp = mysqli_real_escape_string($dbc, trim($_POST['comp']));
    36.     $ncmrid = mysqli_real_escape_string($dbc, trim($_POST['ncmrid']));
    37.     $rma = mysqli_real_escape_string($dbc, trim($_POST['rma']));
    38.     $jno = mysqli_real_escape_string($dbc, trim($_POST['jno']));
    39.     $fdt = mysqli_real_escape_string($dbc, trim($_POST['fdt']));
    40.     $cof = mysqli_real_escape_string($dbc, trim($_POST['cof']));
    41.     $fab1= mysqli_real_escape_string($dbc, trim($_POST['fab1']));
    42.     $fab2= mysqli_real_escape_string($dbc, trim($_POST['fab2']));
    43.     $fab3= mysqli_real_escape_string($dbc, trim($_POST['fab3']));
    44.     $non= mysqli_real_escape_string($dbc, trim($_POST['non']));
    45.     $dis= mysqli_real_escape_string($dbc, trim($_POST['dis']));
    46.     $comm= mysqli_real_escape_string($dbc, trim($_POST['comm']));
    47.     $caad= mysqli_real_escape_string($dbc, trim($_POST['caad']));
    48.     $po= mysqli_real_escape_string($dbc, trim($_POST['po']));
    49.     $pod = mysqli_real_escape_string($dbc, trim(date('Y-m-d',strtotime($_POST['pod']))));
    50.     $dri = mysqli_real_escape_string($dbc, trim(date('Y-m-d',strtotime($_POST['dri']))));
    51.  
    52.  
    53.     $query = "UPDATE ncmr SET ab = '$ab', date = '$date', part = '$part', rev = '$rev' , partdesc = '$partdesc' , ncmrqty = '$ncmrqty' , comp = '$comp' , ncmrid = '$ncmrid' , rma = '$rma' , jno = '$jno' , fdt = '$fdt' , cof = '$cof' , fab1 = '$fab1' , fab2 = '$fab2' , fab3 = fab3' , non = '$non' , dis = '$dis' , comm = '$comm' , caad = '$caad' , po = '$po' , pod = '$pod' , dri = '$dri'  WHERE id = '$id'";
    54.  
    55.  
    56. // echo your raw query and look for obvious errors
    57.      echo "Query is : " . $query . "<br />";
    58.  
    59. // and at least use a basic mechanism to trap possibles errors
    60.        mysqli_query($dbc, $query)  or die('Query Error : ' . mysqli_error($dbc));
    61.  
    62.  
    63. // Clear the data to clear the form
    64.     $id = "";
    65.     $ab = "";
    66.     $date = "";
    67.     $part = "";
    68.     $rev = "";
    69.     $partdesc = "";
    70.     $ncmrqty = "";
    71.     $comp = "";
    72.     $ncmrid = "";
    73.     $rma = "";
    74.     $jno = "";
    75.     $fdt = "";
    76.     $cof = "";
    77.     $fab1= "";
    78.     $fab2= "";
    79.     $fab3= "";
    80.     $non= "";
    81.     $dis= "";
    82.     $comm= "";
    83.     $caad= "";
    84.     $po= "";
    85.     $pod = "";
    86.     $dri = "";         
    87. // Confirm success with the user
    88.         echo '<p>If you wish to edit more NCMRs, please <a href="list.php">go to the admin page!</a></p>';
    89.  
    90.  
    91.             mysqli_close($dbc);
    92.             }
    93.    
    94.   else {   
    95.  
    96. // Connect to the database
    97.   $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    98. // Grab the profile data from the database
    99.   if (!isset($_GET['id'])) {
    100.     $query = "SELECT * FROM ncmr WHERE id = '$id'";
    101.   }
    102.   else {
    103.     $query = "SELECT * FROM ncmr WHERE id = '" . $_GET['id'] . "'";
    104.   }
    105. // echo your raw query and look for obvious errors
    106.      echo "Query is : " . $query . "<br />";
    107.  
    108. // and at least use a basic mechanism to trap possibles errors
    109.        mysqli_query($dbc, $query)  or die('Query Error : ' . mysqli_error($dbc));
    110.  
    111.  
    112.   if (mysqli_num_rows($id) == 1) {
    113. // The user row was found so display the user data
    114.     $row = mysqli_fetch_array($data);
    115.     echo'<div id="title"><h3 id="NCMR2">Non-Conforming Materials Report (NCMR:&nbsp;&nbsp;' . $row['rma'] . ')</h3></div>';
    116. echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>";
    117.     echo '<fieldset>';
    118.            
    119.         echo '<div id="box1">';
    120.             if (empty($row['ab'])) $row['ab'] = "Empty";
    121.             if (empty($row['date'])) $row['date'] = "Empty";
    122.             if (empty($row['part'])) $row['part'] = "Empty";
    123.             if (empty($row['rev'])) $row['rev'] = "Empty";
    124.             if (empty($row['partdesc'])) $row['partdesc'] = "Empty";
    125.             if (empty($row['ncmrqty'])) $row['ncmrqty'] = "Empty";
    126.             echo '<div id="ab"><span class="b">Added By:&nbsp;&nbsp;</span><input type="text" name="ab" value="' . $row['ab'] . '" /></div>';
    127.             echo '<div id="date"><span class="b">Date Filed:&nbsp;&nbsp;</span><input type="text" name="date" value="' . $row['date'] . '" /></div>';
    128.             echo '<div id="part"><span class="b">Part Number:&nbsp;&nbsp;</span><input type="text" name="part" value="' . $row['part'] . '" /></div>';
    129.             echo '<div id="rev"><span class="b">Part Revision:&nbsp;&nbsp;</span><input type="text" name="rev" value="' . $row['rev'] . '" /></div>';
    130.             echo '<div id="partdesc"><span class="b">Part Description:&nbsp;&nbsp;</span><textarea rows="4" cols="22">' . $row['partdesc'] . '</textarea></div>';
    131.             echo '<div id="ncmrqty"><span class="b">NCMR Qty:&nbsp;&nbsp;</span><input type="text" name="ncmrqty" value="' . $row['ncmrqty'] . '" /></div>';
    132.         echo '</div>';
    133.  
    134.  
    135. //Company, Customer NCMR, Internal RMA, and Job Number
    136.         echo '<div id="box2">';
    137.             if (empty($row['comp'])) $row['comp'] = "Empty";
    138.             if (empty($row['ncmrid'])) $row['ncmrid'] = "Empty";
    139.             if (empty($row['rma'])) $row['rma'] = "Empty";
    140.             if (empty($row['jno'])) $row['jno'] = "Empty";
    141.                 echo '<div id="comp"><span class="b">Company:&nbsp;&nbsp;</span><input type="text" name="comp" value="' . $row['comp'] . '" /></div>';
    142.                     echo '<div id="ncmrid"><span class="b">Customer NCMR ID:&nbsp;&nbsp;</span><input type="text" name="ncmrid" value="' . $row['ncmrid'] . '" /></div>';
    143.                     echo '<div id="rma"><span class="b">Internal RMA #:&nbsp;&nbsp;</span><input type="text" name="rma" value="' . $row['rma'] . '" /></div>';
    144.                     echo '<div id="jno"><span class="b">Job #:&nbsp;&nbsp;</span><input type="text" name="jno" value="' . $row['jno'] . '" /></div>';
    145.         echo '</div>';
    146.            
    147. //Type of Failure and Class of Failure
    148.         echo '<div id="box3">';
    149.             echo '<h2>Failure</h2>';
    150.                 echo '<div id="cof"><span class="b">Class of Failure:&nbsp;&nbsp;</span><input type="text" name="cof"  size="15" value="' . $row['cof'] . '" /></div>';
    151.                 echo '<div id="fdt"><span class="b">Failure Due To:&nbsp;&nbsp;</span><input type="text" name="fdt"  size="15" value="' . $row['fdt'] . '" /></div>';
    152.         echo '</div>';
    153.  
    154.  
    155. //Fabricators
    156.         echo '<div id="box4">';
    157.             echo '<h2>Fabricators</h2>';
    158. if ($row['fab1']="--None--")
    159. {
    160.     echo'<div id="fab1">';
    161.     $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    162.     $mysqli->select_db('user');
    163.     $result = $mysqli->query("SELECT * FROM user");
    164.     echo "<SELECT name='fab1'>\n";
    165.     while($row = $result->fetch_assoc())
    166.     {
    167.         echo "<option value='{$row['user']}'>{$row['user']}</option>\n";
    168.     }
    169.     echo "</select>\n";
    170.     echo '</div>';
    171. }
    172. else
    173. {
    174.     echo'<div id="fab1">';
    175.     $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    176.     $mysqli->select_db('user');
    177.     $result = $mysqli->query("SELECT * FROM user");
    178.     echo "<SELECT name='fab1'>\n";
    179.     while($row = $result->fetch_assoc())
    180.     {
    181.         echo "<option value='{$row['user']}'>{$row['user']}</option>\n";
    182.     }
    183.     echo "</select>\n";
    184.     echo '</div>';
    185. }
    186.  
    187.  
    188.  
    189.  
    190. if ($row['fab2']="--None--")
    191. {
    192.     echo'<div id="fab2">';
    193.     $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    194.     $mysqli->select_db('user');
    195.     $result = $mysqli->query("SELECT * FROM user");
    196.     echo "<SELECT name='fab2'>\n";
    197.     while($row = $result->fetch_assoc())
    198.     {
    199.         echo "<option value='{$row['user']}'>{$row['user']}</option>\n";
    200.     }
    201.     echo "</select>\n";
    202.     echo '</div>';
    203. }
    204. else
    205. {
    206.     echo '<div id="fab2"><span class="b"></span><input type="text" name="fab1"  size="20" value="' . $row['fab1'] . '" /></div>';
    207.     echo '</div>';
    208. }
    209. if ($row['fab3']="--None--")
    210. {
    211.     echo'<div id="fab3">';
    212.     $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    213.     $mysqli->select_db('user');
    214.     $result = $mysqli->query("SELECT * FROM user");
    215.     echo "<SELECT name='fab3'>\n";
    216.     while($row = $result->fetch_assoc())
    217.     {
    218.         echo "<option value='{$row['user']}'>{$row['user']}</option>\n";
    219.     }
    220.     echo "</select>\n";
    221.     echo '</div>';
    222. }
    223. else
    224. {
    225.     echo '<div id="fab3"><span class="b"></span><input type="text" name="fab1"  size="20" value="' . $row['fab1'] . '" /></div>';
    226.     echo '</div>';
    227. }       echo '</div>';
    228.  
    229.  
    230. //Nonconformity, Disposition, Comments and Comments & Additional Details
    231.         echo '<div id="box5">';
    232.             if (empty($row['non'])) $row['non'] = "Empty";
    233.             if (empty($row['dis'])) $row['dis'] = "Empty";
    234.             if (empty($row['comm'])) $row['comm'] = "Empty";
    235.             if (empty($row['caad'])) $row['caad'] = "Empty";
    236.  
    237.  
    238.             echo '<div id="non"><span class="b">Nonconformity:&nbsp;&nbsp;</span><textarea rows="4" cols="105">' . $row['non'] . '</textarea></div>';
    239.             echo '<div id="dis"><span class="b">Disposition:&nbsp;&nbsp;</span><textarea rows="4" cols="105">' . $row['dis'] . '</textarea></div>';
    240.             echo '<div id="comm"><span class="b">Comments:&nbsp;&nbsp;</span><textarea rows="4" cols="105">' . $row['comm'] . '</textarea></div>';
    241.             echo '<div id="caad"><span class="b">Comments and/or Additional Details:&nbsp;&nbsp;</span><textarea rows="4" cols="105">' . $row['caad'] . '</textarea></div>';
    242.  
    243.  
    244.                 echo '<div id="podr">';
    245.                         if (empty($row['po'])) $row['po'] ="Empty";
    246.                         if (empty($row['pod'])) $row['pod'] ="Empty";
    247.                         if (empty($row['dir'])) $row['dri'] ="Empty";
    248.  
    249.  
    250.                     echo '<div id="po"><span class="b">PO:&nbsp;&nbsp;</span><input type="text" name="po"  size="7" value="' . $row['po'] . '" /></div>';
    251.                     echo '<div id="pod"><span class="b">PO Date:&nbsp;&nbsp;</span><input type="text" name="pod"  size="7" value="' . $row['pod'] . '" /></div>';
    252.                     echo '<div id="dri"><span class="b">Date Received:&nbsp;&nbsp;</span><input type="text" name="dri"  size="7" value="' . $row['dri'] . '" /></div>';
    253.                 echo '</div>';
    254.             echo '<div id="button2"><input type="submit" value="Submit Edits" name="submit" /></div>';
    255.         echo '</div>';
    256.     echo '</fieldset>';
    257. echo '</form>';
    258.         }
    259.     }
    260.  
    261.  
    262. echo '</div>';
    263.  
    264.  
    265. ?>
    266. </body>
    267. </html>
    268.  
     
    Matt Ridge, Feb 20, 2012 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,660
    Likes Received:
    22
    Best Answers:
    12
    Trophy Points:
    115
    #2
    Have you tried to executing your query in phpmyadmin? and wich line is 104?

    split the code there [ / code ] line 105 start here [ code ]
     
    EricBruggema, Feb 20, 2012 IP
  3. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #3
    I figured what it was, it was a typo on my end, thanks for the help though :)
     
    Matt Ridge, Feb 20, 2012 IP