Accessing Stored Procedures on SQL Server 2005
Posted: Tue Jun 24, 2008 11:15 am
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.
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';
}