MSSQL过程查询返回“无法将值NULL插入列”

时间:2017-05-09 20:35:02

标签: php html css sql-server

我有5个字段的形式。当点击提交按钮时,它将从数据库MSSQL的字段中获取Amount。现在,当我填写表格并提交时,它会给出错误。我已经使用MSSQL过程查询来执行它。请帮帮我,我现在遇到了麻烦。

 <div id="middle_pane">
   <div>
      <div id="inner_pane">
    <div id="center_pane">
    <div id="center_inner_pane">
        <div class="txt_content">
     <table width="385" height="200" style=" border:2px solid silver" 
     cellpadding="6px" cellspacing="0px" align="center" border="0"> 
     <form method="POST" action="<?php bloginfo('url');?>/fedex-tariff">
    <tr> 
    <td colspan="2" style="background:#0066FF; color:#FFFFFF; 
    fontsize:50px">Fedex Rate Card</td></tr>
    <tr> 
    <td>Origin</td>
    <td>
        <select name="origin" id="origin" onChange="">
            <option value="pakistan">Pakistan</option>
        </select>
    </td>
    </tr>
    <tr> 
    <td>Select Origin city </td>
    <td>
        <select name="city_id" id="city_id">
            <option value="">--SELECT CITY--</option>
                <?php 
                 $city  = "select * from branches";
                 $city_query    = mssql_query($city);
                 while ($row_city = mssql_fetch_array($city_query)){
                ?>
                <option value="<?php echo $row_city['name'];?>"> <?php echo 
                $row_city['name']; ?></option>
                <?php } ?>
        </select>
          </td>
        </tr>
     <tr> 
      <td>Select Destination </td>
      <td>
        <select name="country_id" id="country_id">
            <option value="">--SELECT Destination--</option>
                <?php 
                 $service= "select * from country";
                 $service_query= mssql_query($service);
                 while ($row_service = mssql_fetch_array($service_query)){
                ?>
                <option value="<?php echo $row_service['Name'];?>"> <?php 
                echo $row_service['Name']; ?></option>
                <?php } ?>
        </select>
        </td>
       </tr>
        <tr>
            <td> Selection of Weight </td>
         <td>
            <div id="wgt">
                <input type="text" id="weight" name="weight" value="" 
                placeholder="weight...." required="">
            </div> 
          </td>
          </tr>
        <tr>
        <td>Select Your Service</td>
         <td>
            <select name="service_id" id="service_id">
            <option value="">--SELECT--</option>    
            <?php
            $service_type = "SELECT distinct ServiceTypeId from 
            dbo.IntlZoneCountry where ServiceTypeId IN ('FedEx Cash Tariff 
             Docs','FedEx Box','FedEx Student Package')";
            $res_type   = mssql_query($service_type);
            $cnt_type   = mssql_num_rows($res_type);
            while($row_type = mssql_fetch_array($res_type)){
            ?>
            <option value="<?php echo $row_type['ServiceTypeId'];?>"><?php 
             echo $row_type['ServiceTypeId'];?></option>
            <?php } ?>
          </select>
        </td>
        </tr>
        <tr>
          <td> <input type="submit" value="Calculate" name="submit" 
          class="btn"></td>
         </tr>
        </form>
         <table width="385" style=" border:2px solid silver" 
          cellpadding="6px" cellspacing="0px" align="center" border="0"> 
         <tr>
        <td>
        <?php
        if(isset($_POST['submit'])) 
         {
         $city_id       =   $_POST['city_id'];
         $country_id        =   $_POST['country_id'];
         $service_id        =   $_POST['service_id'];
        $weight_id      =   $_POST['weight'];
        if(empty($city_id) || empty($country_id) || empty($service_id) || 
         empty($weight_id)){
          ?><center><?php echo "Please filled all the fields first.";?>
        </center>
         <?php
           } 
        else{
          $s = "[SP_UpdateCNPrice_Int_Tariff] 
          '$weight_id','$city_id','$country_id','$service_id'";

        $result    =  mssql_query($s); 
        while($row   = mssql_fetch_assoc($result)){
         ?>
        </td>
           </tr>    
         <tr style="background:#00CFFF; color:blue;">
           <td>
            <center>
             <font size="3">
              <?php
                    $val = $row['amount'];
                    $gst = $row['gst'];
                    echo "<strong>"."Rate : "."$".""."&nbsp;".$val.$gst;
               ?>  
                 </font> 
              </center>
               </td>
                 </tr>  
               <tr style="background:#00CFFF; color:blue;"> 
                <td><center> All Rates are Exclusive of 16% GST + 23% fuel 
                 Charges (FSC).</center> </td>
                  </tr> 
                <?php
                     }
                  } 
                   }
                  ?>
                   </table>
                </div>
               </div>
                </div>
               </div>
                </div>

MSSQL Procedure Screenshot

Front Display of Website

0 个答案:

没有答案