Jump to content

PHP MSSQL Stored Procedure


stockton
 Share

Recommended Posts

Please tell me what is wrong with the following piece of code:-
$Datum = date("'Y-m-d H:i:s'");
$link = mssql_connect("localhost", "sa", "")
or trigger_error('Could not connect to database', E_USER_ERROR);
mssql_select_db("pm", $link) or trigger_error('Could not select database', E_USER_ERROR);
$proc = mssql_init("spGetActivePromotions", $link);
mssql_bind($proc, "@Today", $Datum, SQLTEXT, FALSE,FALSE,strlen($Datum));
$Result = mssql_execute($proc);
if (!$Result) {
$Message = sprintf("mssql_execute failed for %s [%d].", $Datum, $Result);
trigger_error($Message, E_USER_ERROR);
die();
}
the stored procedure that I am attempting to use looks like :-
CREATE PROCEDURE spGetActivePromotions
@Today datetime
AS
SELECT PromotionID, PromotionName, StartDate, EndDate, LastDrawDate,
MaxDraws, NumRegTickets, VouchersPermitted, NumTicketsPerVoucher, ManualTicketIssue
FROM Promotion
WHERE @Today>=StartDate AND @Today<=EndDate
GO
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.