2017-05-10 6 views
0

これを解決するためにほとんど無駄になりましたが、解決策を見つけることができませんでした。私はPHPを使用してMSSQLの手順に固執しています。私は計算すると "金額"を返す5つのフィールドのフォームを持っています。この手続きはSQl Managemant 2008で完全に動作していますが、PHPコードから実行中にエラーが表示されます。私のコードとスクリーンショットの下で私を助けてください。警告:mssql_execute():メッセージ:ストアドプロシージャを見つけることができません

   <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['zoneCode'];?>"> <?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['Code'];?>"> <?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']; 

       //This is PHP validation 
       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{ 
        $tozoneCode = "Select ZoneCode from dbo.IntlZoneCountry where CountryCode= '$country_id' AND ServiceTypeId= '$service_id'"; 
        $result_tozoneCode = mssql_query($tozoneCode,$conn); 
         while($row = mssql_fetch_assoc($result_tozoneCode)){ 
          $toZone = $row['ZoneCode']; 
         } 
         $result = mssql_query('set ANSI_NULL_DFLT_ON ON',$conn); 
         $stmt = mssql_init('SP_UpdateCNPrice_Int_Tariff',$conn); 

       echo "<pre>"; 
       print_r($stmt); 

        //$weight_id = '5';$city_id = '3';$toZone = 'D';$service_id = 'fedex';$gstPercent='12.2'; 
        mssql_bind($stmt, '@weight', $weight_id, SQLVARCHAR); 
        mssql_bind($stmt, '@FromZone', $city_id, SQLVARCHAR); 
        mssql_bind($stmt, '@ToZone', $toZone, SQLVARCHAR); 
        mssql_bind($stmt, '@serviceType', $service_id, SQLVARCHAR); 

        // $outVar1 = ''; 
        //$outVar2 = ''; 

        // mssql_bind($stmt, '@amount', $outVar1, SQLVARCHAR); 
        //mssql_bind($stmt, '@gst', $outVar2, SQLVARCHAR); 

        //$proc_result = mssql_execute($stmt, true); 

        if ($proc_result = mssql_execute($stmt)){ 
         while ($row = mssql_fetch_assoc($proc_result)){ 
         echo $row["amount"]; 
         } 
        } 
        die("<BR>".mssql_get_last_message()); 
        //print($outVar1); 
        //print($outVar2); 
        mssql_close($conn); 


       // $proc = mssql_init("[SP_UpdateCNPrice_Int_Tariff] '$weight_id','$city_id','$toZone','$service_id'", $conn); 
        //$result = mssql_execute($proc); 
        //print_r($result); 
        /*while($row = mssql_fetch_assoc($result)){ 
        //print_r($row); 
       ?> 
        </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 
        }*/ 
        } 
        } 
       // mssql_close(); 
       ?> 
       </table> 
       </div> 
       </br> 
       <font size="2"><center>For more details <strong><a href="http://ocs.com.pk/customer-care-2">Contact Us</a></strong> at any time.</center></font> 

       <div style="float:right;"></div> 
       </div> 
       </div> 

       </div> 
       </div> 
       </div> 

Rate Card Front end display

MSSQL MANAGEMENT SCREENSHOT

+0

私の最初の考えは、スキーマを修飾することです。 'dbo'で' Select'ステートメントのテーブルを修飾するので、 'dbo'と仮定しています。 –

+0

あなたは今日また戻ってきました!私はあなたが昨夜から修正されたストアドプロシージャのnull値の問題を持っていると思いますか?あなたの接続の一部としてログイン/パスを指定してみて、同じストアドプロシージャをSSMSで直接実行できることを確認できますか? –

+0

返信ありがとうございます。はい私はユーザー名とパスワードをダブルチェックしました –

答えて

0

私はこの同じ問題を抱えていました。

私のPHP - > MSSQLストアドprocsは正しく動作していた後、何かが環境内で変更され、突然コードが動作しなくなりました。

は、私が使用してからの切り替え:

$proc = mssql_init('storedProceedureName', $connection); 
mssql_execute($proc); 

mssql_query('EXEC storedProceedureName', $connection); 

そして、それは再び仕事を始めた突然のすべてを使用します。なぜそれが事実であるかわからないが、私は口の中で贈り物の馬を見るつもりはない。

関連する問題