I have wasted a day almost to solve this but not able to find solution. I am stuck in MSSQL procedure with php. i have a form of 5 fields which return a “Amount” when calculate. The Procedure is working perfectly on SQl Managemant 2008 but it display an error while execute from php code. Please help me please below my code and screenshot.

    <?php
            /*
            Template Name:International tariff Page
            */
            error_reporting(E_ALL ^ E_DEPRECATED);

            get_header();


            $server = 'xxxxxx';
            $db = 'xxxxx';
            $conn = mssql_connect($server, 'xxxxx', 'xxxx');
            mssql_select_db($db,$conn)or die("DB not connected"); 
            ?>


            <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'];
                    }
                $stmt = mssql_init('SP_UpdateCNPrice_Int_Tarrif',$conn);
                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_array($proc_result)){
                    echo $row["amount"];
                    }
                }
                //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>


            </div>
            </div>

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

            <?php get_footer();?>

Rate Card Front end display

MSSQL MANAGEMENT SCREENSHOT

Read more here: Warning: mssql_execute(): message: Could not find stored procedure


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: