Why would an update script do an insert, and not update?

$navtype = $_GET['nav'];	

	if($navtype == "zjxpmovdtzjd")
	{
		        		
		 $mileage_out = $_POST['mileage_out'];
		 $mileage_in = $_POST['mileage_in'];
		 $famount = $_POST['famount'];
		 $vreg = $_POST['vreg'];
		 $driver = $_POST['driver'];
		 $vtype = $_POST['vtype'];
		 $desti = $_POST['desti'];		 	 		 
		 $date_out = $_POST['dy']."-".$_POST['dm']."-".$_POST['dd'];
		 $date_in  = $_POST['ay']."-".$_POST['am']."-".$_POST['ad'];
		 $cur_date = date("d-m-y H:i:s");		 
		 $outl = $_POST['outl'];
		 $out2 = $_POST['out2'];
		 $pload = $_POST['pload'];
		 $con_size = $_POST['con_size'];
		 $sup_name = $_POST['sup_name'];
		 $s_veration = $_POST['s_veration'];
		 $remnder_ver = $_POST['remnder_ver'];
		 $tf_con = ($_POST['mileage_in'] - $_POST['mileage_out']);
		 $tf_con = ($famount * 100) / $tf_con;
		 $tt_con = $_POST['tt_con'];
		 
		 $sql = "UPDATE movlog 
			 
			 SET 
		 
(mileage_out='$mileage_out',mileage_in='$mileage_in',famount='$famount',vreg='$vreg',driver='$driver',vtype='$vtype',desti='$desti',date_out='$date_out',date_in='$date_in',cur_date='$cur_date',outl='$outl',out2='$out2',
pload='$pload',con_size='$con_size',sup_name='$sup_name',s_veration='$s_veration',remnder_ver='$remnder_ver',
tf_con='$tf_con',tt_con='$tt_con' WHERE id='$id')";
		 
		 mysql_query($sql);
		 
		 $sqlx = "UPDATE sre_log SET current_mileage = '$mileage_in' WHERE vreg='$vreg'";
		 mysql_query($sqlx);
		 
		 echo "<center><p><br><br><br><strong>The movement log for $vreg has been UPDATE.</strong></p>";
		 		 	 
	}

The form

<?php
<form action="verxbh738hxzge2d8a.php?nav=zjxpmovdtzjd" method="post" enctype="multipart/form-data" name="myFormj" id="myFormj" onsubmit="return validateForm(this)" target="_blank">
                              <fieldset>
                        		<legend>
                        		 <font color="#666666">Movement / Consumption Information</font></legend>
								 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                                  <tr>
                                    <td><table width="100%" border="0" cellspacing="1" cellpadding="1">
                                    		<tr>
                                        <td width="38%" valign="bottom"><font color="#666666" class="bodyTxt">Mileage [ Departure ] :
                                        		<input type="text" name="id" value="<?php echo $id ?>" />
                                        		</font></td>
                                        <td colspan="2" valign="bottom"><font color="#666666" class="bodyTxt">Mileage [ Arrival ] :</font></td>
                                        <td valign="bottom"><font color="#666666" class="bodyTxt">
                                        		<legend class="bodyTxt"></legend></td>
                                      </tr>
                                      <tr>
                                        <td><input name="mileage_out" type="text" class="bodytxt" id="mileage_out" value="<?php echo $mileage_out ?>" /></td>
                                        <td colspan="2"><input name="mileage_in" type="text" class="bodytxt" id="mileage_in" value="<?php echo $mileage_in ?>" /></td>
                                        <td width="20%">&nbsp;</td>
                                      </tr>
                                      <tr>
                                        <td height="23" valign="bottom"><font color="#666666" class="bodyTxt">Vehicle Registration # :</font></td>
                                        <td colspan="2" valign="bottom"><font color="#666666" class="bodyTxt">Fuel Filled (LTRS)  :</font></td>
                                        <td>&nbsp;</td>
                                      </tr>
                                      <tr>
                                        <td>
                                        <select name="vreg" class="bodytxt" id="vreg">
																					<option selected="selected"><?php echo $vreg?></option>
                                      <?php
																				$query = "select id,vreg FROM vreg_no order by vreg";
																				$movlog_result= mysql_query($query) or trigger_error("SQL", E_USER_ERROR);
																				$movlog_num = 0;
																				$movlog_num = mysql_numrows($movlog_result);
																				$i = 0;
																				$x = 0;
																					$tempvreg = "";
																					while($i < $movlog_num) 
																					{
																						$vreg = mysql_result($movlog_result,$i,"vreg");
																						$fid = mysql_result($movlog_result,$i,"id");
																						if($vreg != $tempvreg)
																						{
																							echo"<option value='$vreg'>$vreg</option>";
																							$tempvreg = $vreg;
																						}
																						$i++;
																					}
																		?>
                                        </select></td>
                                        <td colspan="2"><input name="famount" type="text" class="bodytxt" id="famount" value="<?php echo $famount ?>" /></td>
                                        <td>&nbsp;</td>
                                      </tr>
                                      <tr>
                                        <td height="23" valign="bottom"><legend class="bodyTxt"><font color="#666666" class="bodyTxt">Driver / Operator :</font></legend></td>
                                        <td colspan="2" valign="bottom"><span class="bodyTxt"><font color="#666666"><!--Fuel Cost (Gh &cent;) :--></font><font color="#666666" class="bodyTxt">Supplier's
                                        						Name :</font></span></td>
                                        <td rowspan="2">&nbsp;</td>
                                      </tr>
                                      <tr>
                                        <td valign="bottom"><input name="driver" type="text" class="bodytxt" size="25" id="driver" value="<?php echo $driver ?>" /></td>
                                        <td colspan="2" valign="bottom"><!--<input name="fuel_cost" type="text" class="bodytxt" size="25" id="fuel_cost" />-->
                                        		<select name="sup_name" class="bodytxt" id="sup_name">
                                        				<option><?php echo $sup_name ?></option>
                                        				<?php
																					
																						$query = "select id,uz_ze FROM supplier order by uz_ze";
																						$movlog_result= mysql_query($query) or trigger_error("SQL", E_USER_ERROR);
																						$movlog_num = 0;
																						$movlog_num = mysql_numrows($movlog_result);
																						$i = 0;
																						$x = 0;
																							$tempvreg = "";
																							while($i < $movlog_num) 
																							{																								
																								$id = mysql_result($movlog_result,$i,"id");
																								$uz_ze = mysql_result($movlog_result,$i,"uz_ze");
																								if($uz_ze != $tempvreg)
																								{
																									echo"<option value='$uz_ze'>$uz_ze</option>";
																									$tempvreg = $uz_ze;
																								}
																								$i++;
																							}
																				?>
                                        				</select></td>
                                      </tr>
                                      <tr>
                                        <td><font color="#666666" class="bodyTxt">Vehicle Type :</font></td>
                                        <td colspan="2"><font color="#666666" class="bodyTxt">Destination :</font></td>
                                        <td class="bodyTxt" valign="bottom">&nbsp;</td>
                                      </tr>
                                      <tr>
                                        <td height="24" valign="bottom">
                                        <select name="vtype" class="bodytxt" id="vtype">
																				<option><?php echo $vtype ?></option>
                                          <?php
																					
																						$query = "select * FROM vty order by vreg";
																						$movlog_result= mysql_query($query) or trigger_error("SQL", E_USER_ERROR);
																						$movlog_num = 0;
																						$movlog_num = mysql_numrows($movlog_result);
																						$i = 0;
																						$x = 0;
																							$tempvreg = "";
																							while($i < $movlog_num) 
																							{																								
																								$id = mysql_result($movlog_result,$i,"id");
																								$vreg = mysql_result($movlog_result,$i,"vreg");
																								if($vreg != $tempvreg)
																								{
																									echo"<option value='$vreg'>$vreg</option>";
																									$tempvreg = $vreg;
																								}
																								$i++;
																							}
																				?>
                                        </select></td>
                                        <td colspan="2" valign="bottom"><font color="#666666" class="bodyTxt"><!--Department :-->
                                          <label>
                                            <input type="text" name="desti" id="desti" class="bodytxt" value="<?php echo $famount ?>" />
                                          </label>
                                        </font></td>
                                        <td>&nbsp;</td>
                                      </tr>
                                      <tr>
                                        <td height="24" valign="bottom"><font color="#666666" class="bodyTxt">Container Size :</font></td>
                                        <td colspan="2" valign="bottom"><font color="#666666" class="bodyTxt">Load Type :</font></td>
                                        <td>&nbsp;</td>
                                      </tr>
                                      <tr>
                                        <td height="77" rowspan="3" valign="top">
                                        <select name="con_size" class="bodytxt" id="con_size">
                                          <option><?php echo $con_size ?></option>
                                          <?php
																					
																						$query = "select id,uz_ze FROM cuz_size order by uz_ze";
																						$movlog_result= mysql_query($query) or trigger_error("SQL", E_USER_ERROR);
																						$movlog_num = 0;
																						$movlog_num = mysql_numrows($movlog_result);
																						$i = 0;
																						$x = 0;
																							$tempvreg = "";
																							while($i < $movlog_num) 
																							{																								
																								$id = mysql_result($movlog_result,$i,"id");
																								$uz_ze = mysql_result($movlog_result,$i,"uz_ze");
																								if($uz_ze != $tempvreg)
																								{
																									echo"<option value='$uz_ze'>$uz_ze</option>";
																									$tempvreg = $uz_ze;
																								}
																								$i++;
																							}
																				?>
                                        </select>
                                        </td>
                                        <td colspan="2" valign="top" class="bodytxt">
                                        
                                        		<select id="selectMenu" name="outl" onchange="test()" class="bodytxt">
                                        				<option value="" selected><?php echo $outl ?></option>
                                        				<option class="bodytxt" value="Office Load">Office Load</option>
                                        				<option class="bodytxt" value="Outside Load">Outside Load</option>
                                        				</select></td>
                                        <td></td>
                                      </tr>
                                      <tr>
                                      		<td colspan="3" valign="top" align="left" class="bodytxt">
																					Specific Load Point : <font color="#FF0000">
																					<strong><?php echo $out2 ?></strong></font></td>
                                      		</tr>
                                      <tr>
                                      		<td colspan="2" valign="top" class="bodytxt"><p id="demo1"></p></td>
                                      		<td></td>
                                      		</tr>
                                    </table>
																		</td>
                                  </tr>
                                  <tr>
                                    <td valign="top"> 
                                      
                                    <fieldset>
                        		<legend class="bodyTxt">
               <font color="#666666">Date / Days Spent</font> <span class="bodytxt">
            <input name='cur_date' type='hidden' value="<?=date('d-m-y H:i:s')?>"/>
                 </legend>
								 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
         <td width="47%" height="70" align="center" valign="top">
         <table width="96%" border="0" align="center" cellpadding="1" cellspacing="1">
           <tr>
             <th scope="col" colspan="3" class="bodyTxt"></th>
                </tr>
                <tr>
               <th scope="col" colspan="3" class="bodyTxt" align="left">
		<font color="#666666" class="bodyTxt">
		<font color="#FF0000"><?php echo "$date_out";?></font></font>
		<font color="red">*</font>
		</th>
                   </tr>
		<th scope="col" colspan="3" class="bodyTxt" align="left">
		<font color="#666666" class="bodyTxt">
		<font color="#000000">Departure Date :</font>
		</font><font color="red">*</font></th>
                </tr>
                <tr>
                 <td class="bodytxt"> Day :
            <select name="dd" class="bodytxt" id="dd">
										<option value="01">1</option>
                 <option value="02">2</option>
                <option value="03">3</option>
                 <option value="04">4</option>
                 <option value="05">5</option>
                 <option value="06">6</option>
                 <option value="07">7</option>
                 <option value="08">8</option>
                 <option value="09">9</option>
                 <option value="10">10</option>
                 <option value="11">11</option>
                 <option value="12">12</option>
                 <option value="13">13</option>
                 <option value="14">14</option>
                 <option value="15">15</option>
                <option value="16">16</option>
                 <option value="17">17</option>
                 <option value="18">18</option>
                 <option value="19">19</option>
                <option value="20">20</option>
                 <option value="21">21</option>
                <option value="22">22</option>
                <option value="23">23</option>
                 <option value="24">24</option>
                <option value="25">25</option>
               <option value="26">26</option>
              <option value="27">27</option>
             <option value="28">28</option>
            <option value="29">29</option>
          <option value="30">30</option>
       <option value="31">31</option>
   </select></td>
                  <td class="bodytxt"> Month :
                  <select name="dm" class="bodytxt" id="dm">
                  <option value="01">1</option>
                 <option value="02">2</option>
                 <option value="03">3</option>
                 <option value="04">4</option>
                 <option value="05">5</option>
                <option value="06">6</option>
              <option value="07">7</option>
            <option value="08">8</option>
          <option value="09">9</option>
           <option value="10">10</option>
            <option value="11">11</option>
             <option value="12">12</option>
              </select></td>

              <td class="bodytxt"> Year :
              <select name="dy" class="bodytxt" id="dy">
             <option value="2011">2011</option>
             <option value="2012">2012</option>
             <option value="2013">2013</option>
             <option value="2014">2014</option>
             <option value="2015">2015</option>
             <option value="2016">2016</option>
             <option value="2017">2017</option>
             <option value="2018">2018</option>
             <option value="2019">2019</option>
             <option value="2020">2020</option>
             </select>
</td>
                                      </tr>
                                    </table></td>
           <td width="1%" align="center" bgcolor="#006600"></td>
            <td width="1%" align="center" bgcolor="#ffffff"></td>
      <td width="49%" align="center" valign="top">
     <table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
     <tr>
      <th scope="col" colspan="3" class="bodyTxt"></th>
        </tr>
          <tr>
           <th scope="col" colspan="3" class="bodyTxt" align="left">
	<font color="#666666" class="bodyTxt">
	<font color="#FF0000"><?php echo "$date_in";?></font></font>
	<font color="red">*</font>
	</th>
                                      </tr>
																			<tr>
   <th scope="col" colspan="3" class="bodyTxt" align="left">
<font color="#666666" class="bodyTxt">
<font color="#000000">Arrival Date :</font></font>
<font color="red">*</font>
</th>
             </tr>
            <tr>
            <td width="34%" class="bodytxt"> Day :
            <select name="ad" class="bodytxt" id="ad">
            <option value="01">1</option>
            <option value="02">2</option>
            <option value="03">3</option>
            <option value="04">4</option>
            <option value="05">5</option>
            <option value="06">6</option>
            <option value="07">7</option>
            <option value="08">8</option>
            <option value="09">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
            <option value="26">26</option>
            <option value="27">27</option>
            <option value="28">28</option>
            <option value="29">29</option>
            <option value="30">30</option>
            <option value="31">31</option>
            </select></td>
            <td width="32%" class="bodytxt"> Month :
            <select name="am" class="bodytxt" id="am">
            <option value="01">1</option>
            <option value="02">2</option>
            <option value="03">3</option>
            <option value="04">4</option>
            <option value="05">5</option>
            <option value="06">6</option>
            <option value="07">7</option>
            <option value="08">8</option>
            <option value="09">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            </select></td>
            <td width="34%" class="bodytxt"> Year :
            <select name="ay" class="bodytxt" id="ay">
            <option value="2011">2011</option>
            <option value="2012">2012</option>
            <option value="2013">2013</option>
            <option value="2014">2014</option>
            <option value="2015">2015</option>
            <option value="2016">2016</option>
            <option value="2017">2017</option>
            <option value="2018">2018</option>
            <option value="2019">2019</option>
            <option value="2020">2020</option>
                               </select></td>
                                      </tr>
                                    </table></td>
                                  </tr>
                                </table>
                                </fieldset></td>
                                  </tr>
                                  <tr>
                                    <td></td>
                                  </tr>
                                  <tr>
                                    <td></td>
                                  </tr>
                                  <tr>
                                    <td class="bodytxt">
                                 </td>
                                  </tr>
                                  <tr>
                                    <td align="center">
																		<br />
																		<label>
 <?php 
								if ($_SESSION['login1']== "Superadmin" or $_SESSION['login1']=="Administrator")
{
	echo"
   <input name='button' type='submit' class='bodytxt' id='button' value='Add Movement Log' />
             </label><label>
           <input name='Reset' type='reset' class='bodytxt' id='button' value='Reset' />																		";
	}
?>
Member Avatar for diafol

ho ho ho 400 lines of code! :) Hmm, I may get back to you in a few days after I trawl through all that.

ho ho ho 400 lines of code! :) Hmm, I may get back to you in a few days after I trawl through all that.

LOL,

Let start with this

$navtype = $_GET['nav'];	
 
	if($navtype == "zjxpmovdtzjd")
	{
 
		 $mileage_out = $_POST['mileage_out'];
		 $mileage_in = $_POST['mileage_in'];
		 $famount = $_POST['famount'];
		 $vreg = $_POST['vreg'];
		 $driver = $_POST['driver'];
		 $vtype = $_POST['vtype'];
		 $desti = $_POST['desti'];		 	 		 
		 $date_out = $_POST['dy']."-".$_POST['dm']."-".$_POST['dd'];
		 $date_in  = $_POST['ay']."-".$_POST['am']."-".$_POST['ad'];
		 $cur_date = date("d-m-y H:i:s");		 
		 $outl = $_POST['outl'];
		 $out2 = $_POST['out2'];
		 $pload = $_POST['pload'];
		 $con_size = $_POST['con_size'];
		 $sup_name = $_POST['sup_name'];
		 $s_veration = $_POST['s_veration'];
		 $remnder_ver = $_POST['remnder_ver'];
		 $tf_con = ($_POST['mileage_in'] - $_POST['mileage_out']);
		 $tf_con = ($famount * 100) / $tf_con;
		 $tt_con = $_POST['tt_con'];
 
		 $sql = "UPDATE movlog 
 
			 SET 
 
(mileage_out='$mileage_out',mileage_in='$mileage_in',famount='$famount',vreg='$vreg',driver='$driver',vtype='$vtype',desti='$desti',date_out='$date_out',date_in='$date_in',cur_date='$cur_date',outl='$outl',out2='$out2',
pload='$pload',con_size='$con_size',sup_name='$sup_name',s_veration='$s_veration',remnder_ver='$remnder_ver',
tf_con='$tf_con',tt_con='$tt_con' WHERE id='$id')";
 
		 mysql_query($sql);
 
		 $sqlx = "UPDATE sre_log SET current_mileage = '$mileage_in' WHERE vreg='$vreg'";
		 mysql_query($sqlx);
 
		 echo "<center><p><br><br><br><strong>The movement log for $vreg has been UPDATE.</strong></p>";

why not start with this

<?php
<form action="verxbh738hxzge2d8a.php?nav=zjxpmovdtzjd" method="post" enctype="multipart/form-data"

php is not html

why not start with this

<?php
<form action="verxbh738hxzge2d8a.php?nav=zjxpmovdtzjd" method="post" enctype="multipart/form-data"

php is not html

can you please explain what you mean,pls.

i tryed this

<form action="verxbh738hxzge2d8a.php?nav=zjxpmovdtzjd" method="post" enctype="multipart/form-data">

but its the same

the code supplied is in error
the html inside the <?php ?> will not be parsed, it is not echo heredoc or php is not dropped back to html
eample

<?php
echo '<form action="verxbh738hxzge2d8a.php?nav=zjxpmovdtzjd" method="post" enctype="multipart/form-data" ';

the rest of the file is wrong as well, dont just wrap a html file in <?php ?> and expect it to work
get, and use, an editor with code highlighting
read the php manual
clean up your code <font color="#666666" class="bodyTxt"><font color="#000000">Arrival Date :</font></font> is stupid,

the code supplied is in error
the html inside the <?php ?> will not be parsed, it is not echo heredoc or php is not dropped back to html
eample

<?php
echo '<form action="verxbh738hxzge2d8a.php?nav=zjxpmovdtzjd" method="post" enctype="multipart/form-data" ';

the rest of the file is wrong as well, dont just wrap a html file in <?php ?> and expect it to work
get, and use, an editor with code highlighting
read the php manual
clean up your code <font color="#666666" class="bodyTxt"><font color="#000000">Arrival Date :</font></font> is stupid,

LOL, amazing, i just found out that i was using an insert script i wrote for an update.Thanks for your time and help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.