Accessing Stored Procedures on SQL Server 2005

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

Accessing Stored Procedures on SQL Server 2005

Post by lettie_dude »

Hi

New to MSSQL so be gentle. Have set up some stored procedures to access the DB. One lists all products in a table and works fine. However I have set one up to use a parameter to select one product based on its ID. The code I have is below. Currently it shows absolutely nothing when returning the page. However if I take out the 3000 which is the parameter it throws an error stating the procedure needs a parameter! So it is doing what it should but no records are being returned and yes there is a product with an ID of 3000.

Any help much appreciated.

Code: Select all

 
$prodresult = mssql_query("ListSingleProduct 3000");
 
    $row = mssql_fetch_row($prodresult);
    
    if($row) {
    
        while($prodrow = mssql_fetch_array($prodresult, MSSQL_NUM)) {
            echo 'Product ID: '.$prodrow[0];
            echo '<br/>';
            echo 'Product Name: '.$prodrow[1];
            echo '<br/>';
            echo 'Product Price: '.$prodrow[2];
            echo '<br/>';
            echo 'Product Description: '.$prodrow[3];
        }
    
    } else {
    
        echo 'No Data returned';
        
    }
Post Reply