/    Sign up×
Community /Pin to ProfileBookmark

Problem with MSSQL Server 2000 Stored Procedures

Hallo Guys,
I really need your help. I try to execute Stored Procedure from MSSQL Server 2000. This is the very first time for me, so i look up from the internet and i found example from this site : [url]http://www.devarticles.com/c/a/PHP/Executing-SQL-Server-Stored-Procedures-With-PHP/4/[/url]

the scripts are :

[B]– Create the Stored Procedures :[/B]

[COLOR=”Blue”]USE Northwind

GO

CREATE PROC sp_GetNumProdsByPrice

@minPrice MONEY,

@maxPrice MONEY,

@lowestPricedProduct VARCHAR(40) OUTPUT,

@highestPricedProduct VARCHAR(40) OUTPUT

AS

SELECT @lowestPricedProduct = (SELECT TOP 1 ProductName

FROM Products

WHERE UnitPrice >= @minPrice

ORDER BY UnitPrice ASC)

SELECT @highestPricedProduct = (SELECT TOP 1 ProductName

FROM Products

WHERE UnitPrice <= @maxPrice

ORDER BY UnitPrice DESC)

RETURN (SELECT COUNT(*) FROM Products WHERE UnitPrice >= @minPrice AND UnitPrice <= @maxPrice)[/COLOR]

[B]– The PHP scripts are :[/B]

[COLOR=”Red”]<?php

$myServer = “localhost”;

$myUser = “sa”;

$myPass = “”;

$myDB = “Northwind”;

$s = @mssql_connect($myServer, $myUser, $myPass)

or die(“Couldn’t connect to SQL Server on $myServer”);

$d = @mssql_select_db($myDB, $s)

or die(“Couldn’t open database $myDB”);

$query = mssql_init(“sp_GetNumProdsByPrice”, $s);

$minPrice = 0.00;

$maxPrice = 35.00;

$lowProd = “”;

$highProd = “”;

$numProds = 0;

// Bind the parameters

mssql_bind($query, “@minPrice”, $minPrice, SQLFLT8);

mssql_bind($query, “@maxPrice”, $maxPrice, SQLFLT8);

mssql_bind($query, “@lowestPricedProduct”, &$lowProd, SQLVARCHAR, TRUE, FALSE, 40);

mssql_bind($query, “@highestPricedProduct”, &$highProd, SQLVARCHAR, TRUE, FALSE, 40);

// Bind the return value

mssql_bind($query, “RETVAL”, &$numProds, SQLINT2);

mssql_execute($query);

echo “<h2>There were $numProds products returned.</h2>”;

echo “The lowest priced product was $lowProd.<br>”;

echo “The highest priced product was $highProd.”;

?>[/COLOR]

after i check on my browser, i found some errors message like this :

[B][COLOR=”Red”]Warning: mssql_execute(): message: Could not find stored procedure ‘sp_GetNumProdsByPrice’. (severity 16) in c:inetpubwwwrootprojectcis web versiontest.sp.php on line 44

Warning: mssql_execute(): stored procedure execution failed in c:inetpubwwwrootprojectcis web versiontest.sp.php on line 44

There were 0 products returned.
The lowest priced product was .
The highest priced product was . [/COLOR][/B]

Are there something wrong with the scripts or i need to add some library for php, for your information, i was able to connect PHP with MSSQL Server, there is no problem with the connection.

Please help me ?

And Thank You for Your Answer

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @baltazhor200401 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...