data not storing into the mysql database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • impin
    New Member
    • Jul 2010
    • 127

    data not storing into the mysql database?

    this is my form...
    Code:
     <form action="savesalary.php" method="post">
    
    <table width=100% border=0 bordercolor="#CC6633">
    
    <tr>
    						<tr>
                            <td>Employee Id: </td>
                            
         	  <?php
    		  $empid=$_GET['id'];
    		  
                                print"<td><input type='text' name='empid' value='$empid'></td>";
    							?>
    							
                            
                            </tr>
    
                            <tr>
                            <td>No of Days in Month: </td>
                            <td>
         	  
                                <input type='text' name='ndm'>
    							
                            </td>
                            </tr>
                             <tr>
                            <td>No of Days Present: </td>
                            <td>
         	  
                                <input type='text' name='ndp'>
    							
                            </td>
                            </tr>
                             <tr>
                            <td>Week Offs: </td>
                            <td>
         	  
                                <input type='text' name='woffs'>
    							
                            </td>
                            </tr>
                             <tr>
                            <td>Additions: </td>
                            <td>
         	  
                                <input type='text' name='add'>
    							
                            </td>
                            </tr>
                             <tr>
                            <td>Deductions: </td>
                            <td>
         	  
                                <input type='text' name='ded'>
    							
                            </td>
                            </tr>
                          
    
    <tr>
    <td colspan="2" align="center"><input type="submit" name="submit" value="Send"></td>
    </tr>

    this is my savesalary.php


    Code:
    <?php
    include("config.php");
    $empid=$_POST['empid'];
    $query="SELECT * FROM employee WHERE empid='$empid'";
    $result=mysql_query($query);
    $num=mysql_numrows($result);
    $i=0;
    while ($i < $num)
    {
       $fsal = mysql_result($result, $i,"fsal");
        $i++;
    }
    
    
    $empid=$_POST['empid'];
    $ndm=$_POST['ndm'];
    $ndp = $_POST['ndp'];
    $woffs= $_POST['woffs']; 
    $add = $_POST['add'];
    $ded = $_POST['ded'];
    $month = date ("M-Y");
    
    $tdaysp = ($ndp)+($woffs);
    $ds = ($fsal/$ndm);
    $t = ($ds)* ($tdaysp);
    $total = ($t)+($add)-($ded);
    $sal= round($total);
    
    $query1 = "insert into salary (empid, ndm, ndp, woffs, add, ded, month, total) 
    values ('$empid', '$ndm' ,'$ndp','$woffs' ,'$add','$ded','$month','$sal')";
    mysql_query($query1);
    
    //print "Data Updated Sucessfully";
    ?>

    the data is not storing into the salary table... why?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    READ FIRST: Turn On PHP Debugging Messages

    Try that. Right now your code is completely ignoring the result of the query. You need to print the error if you want to debug it.

    Comment

    • impin
      New Member
      • Jul 2010
      • 127

      #3
      i find it.. i changed the variable name "add" to "adds" and it works...

      Comment

      Working...